ステータスバーの通知をクリアするのに苦労しています。
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;
サービスをキャンセルしようとすると、ステータス バーがクリアされ、アプリがクラッシュします。