0

I am using rooted device and i want to clear the other apps notification programatically from the status bar. I tried this :

NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();

but this is not working in my tablet

1 Answers1

0

It seems that since API 18, this method (notificationManager.cancellAll()) no longer works as expected, but I'm not sure about it. It looks like you need to create listener, which will listen when notifications are created and cancelled, store their objects somewhere and then you'll be able to remove objects and cancel notifications.

Check out this answer for details: https://stackoverflow.com/a/31233518/1150795.

Piotr Wittchen
  • 3,853
  • 4
  • 26
  • 39
  • is there any other way to clear it without storing all id's – Shubham Dubey Jul 31 '18 at 12:31
  • Maybe there is, but I don't know it. If `manager.cancellAll()` doesn't work (IMO it should if it's in the API and is not deprecated), I'd go with collecting all notification ids and cancelling each notification individually in the loop. – Piotr Wittchen Jul 31 '18 at 12:50