我不知道如何清除一個通知狀態。
public void NotificationStatus(){
Intent intent = new Intent(this, Stimulation.class);
NotificationManager notificationManager
= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(
david.flanagan.android.VenAssist.Activities.R.drawable.notification_icon,
"VenAssist Stimulation ON", System.currentTimeMillis());
PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
notification.flags |= Notification.FLAG_ONGOING_EVENT;
notification.flags |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.setLatestEventInfo(this, "VenAssist",
"Stimulation Started", activity);
notificationManager.notify(0, notification);
}
我想在服務器的onDestroy()函數中通過調用 notification.cancel(0);
來清除通知狀態。
我創建了一個通知的實例,不確定對不對。
private NotificationManager notification;
我想取消服務時,因此清除 status bar,程序就崩潰了。
加上第一句試試:
NotificationManager m_NotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
m_NotificationManager.cancel(0);