How to clear a notification in Android


Question

Is it possible to clear a notification programatically?

I tried it with the NotificationManager but its not working. Is there any other way I can do it?

1
92
11/8/2013 6:58:44 AM

Use the following code to cancel a Notification:

NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);

In this code there is alway the same id used for notifications. If you have different notifications that need to be canceled you have to save the ids that you used to create the Notification.

219
11/2/2012 10:20:57 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon