I want to remove all cancelable notifications from status bar. I know how to remove my app notifications I have seen this post before, butI want to remove other apps notifications.
There is a "Clear" button in notifications in all android versions which clears all notifications with this flag: Notification.FLAG_AUTO_CANCEL
That means it's possible to cancel all notifications. But I haven't found any document about how to do that. Is there anybody guide me how to do that?
Thanks
Starting with API Level 18 you can cancel Notifications posted by other apps different than your own using
NotificationListenerService
, the method changed a little in Lollipop, here is the way to remove notifications covering also Lillipop API.First inside the
onNotificationPosted
method you store all theStatusBarNotification
objects. Then you should maintain an updated reference to those objects, removing them if the notification is somehow dismissed inonNotificationRemoved
method.Finally you can remove any notification using
cancelNotification
method.