我正在嘗試構建一種通知方法,當檢測到特定的信標時,會導致通知出現在鎖定的屏幕上。我的理解是,我需要在下面的代碼包括.setVisibility(0):找不到符號類NotificationManagerCompat
public void showNotification(Beacon beacon) {
Resources r = getResources();
int random = (int)System.currentTimeMillis();
Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(android.R.drawable.ic_popup_reminder)
.setContentTitle("Beacons Found")
.setContentText(beacon.getID().toString())
.setVisibility(0) // allow notification to appear on locked screen
.setAutoCancel(true)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(random, notification);
}
我上面的代碼,但是當我運行它,它說:「無法找到符號變量SetVisibility」。我在網上做了一些研究,似乎我需要進口這樣的:
import android.support.v4.app.NotificationManagerCompat;
但是,如果我有這個import語句,它會說「找不到符號類NotificationManagerCompat」
我應該怎麼辦?我已經安裝了Android的支持庫SDK,並有「項目的libs文件夾Android的支持,v4.jar