Remove the notification icon from the status bar

Use the NotificationManager to cancel your notification. You only need to provide your notification id.

https://developer.android.com/reference/android/app/NotificationManager.html

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);

Leave a Comment