Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: remove notification from notification bar

People also ask

How do I remove items from my notification bar?

any options you want to remove from the notification bar. Tap on any of the switches to turn them on or off. This removes these options from the notification bar.

How do I edit my notification bar?

Open Material Status bar app on your Android device and tap on the Customize tab (See image below). 2. On the Customize screen, you will see the following Customization options. In addition to the customize tab, the Notification Shade tab also allows you to fully customize the notification center.


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.


this will help:

NotificationManager mNotificationManager = (NotificationManager)
            getSystemService(NOTIFICATION_SERVICE);
mNotificationManager.cancelAll();

this should remove all notifications made by the app

and if you create a notification by calling

startForeground();

inside a Service.you may have to call

stopForeground(false);

first,then cancel the notification.