Android: remove notification from notification bar Android: remove notification from notification bar android android

Android: remove notification from notification bar


You can try this quick code

public static void cancelNotification(Context ctx, int notifyId) {    String ns = Context.NOTIFICATION_SERVICE;    NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns);    nMgr.cancel(notifyId);}


This is quite simple. You have to call cancel or cancelAll 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)


You can also call cancelAll on the notification manager, so you don't even have to worry about the notification ids.

NotificationManager notifManager= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);notifManager.cancelAll();

EDIT : I was downvoted so maybe I should specify that this will only remove the notification from your application.