views:

441

answers:

1

Hi , I have creating an application and with an event I menage to add notification in android notification bar. Now I need sample how to remove that notification from notification bar on an event ??

+4  A: 

This is quite simple. You have to call cancel on your NotificationManager. The parameter of the cancel method is the ID of the notification that should be canceled.

See the API: http://developer.android.com/reference/android/app/NotificationManager.html#cancel(int)

Roflcoptr
Thanks Roflcoptr :) I found it here : http://stackoverflow.com/questions/2839727/remove-the-notification-icon-from-the-status-bar
zire
private static final int MY_NOTIFICATION_ID= 1234;String ns = Context.NOTIFICATION_SERVICE;NotificationManager mNotificationManager;mNotificationManager = (NotificationManager) getSystemService(ns);mNotificationManager.notify(MY_NOTIFICATION_ID, notification);The example code is not complete. It depends on how your created your notification. Just make sure you use the same id to cancel your notification as you used when you created your notification.To cancel:mNotificationManager.cancel(MY_NOTIFICATION_ID);
zire