I have a service1 broadcasts the service status to MainActivity, MainActivity sends a notification after receive the broadcast. This notification is flagged as a non cancelable notification. In order to cancel the notification when the app is killed from the task panel, I binded the activity with KillNotificationsService which is provided in Cancel notification on remove application from multitask panel for the solution to cancel notification. I also need to cancel the notification when service1 stops. So I put
@Override
public void onDestroy(Intent intent) {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(KillNotificationsService.NOTIFICATION_ID);
}
(NOTIFICATION ID is a static variable in KillNotificationsService).
After I canceled this notification, the next time I start service1, after service1 broadcasts the status, the notification with same id(NOTIFICATION_ID) won't appear. I tried to assign unique Ids and gc for the notification, but it didn't seem working.
If anyone can help me.