我很难清除状态栏通知。
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;
当我尝试取消服务,从而清除状态栏时,应用程序崩溃。