Reputation: 8818
I want to delete all the notification that are present in the top bar. For that I use the following code.
notification = (NotificationManager) mContextNotification.getSystemService(NOTIFICATION_SERVICE);
if(mNotificationManager != null)
mNotificationManager.cancelAll();
But no notification is deleting from the bar. What is the problem in my code?
Upvotes: 1
Views: 1846
Reputation: 3412
You are declaring notification
but trying to use mNotificationManager
?
I personally had no trouble removing all notifications when my app is resumed:
@Override
public void onResume() {
super.onResume();
mNotificationManager.cancelAll();
}
The mNotificationManager is declared like yours (only called the correct thing). It should never be null if you create it with the system service in onCreate like that and do the cancel on it some time later.
Upvotes: 2