How to remove an android push notification from notification center when the app gets started by its launcher icon?

StackOverflow https://stackoverflow.com//questions/25019547

Question

I'd like to remove all pending notifications, if the user starts the app via the launcher icon. This is kind of related to this question (iOS) How to catch all iOS Push Notifications with different user actions including tap on app icon , only that i don't care about any data/info from the notifications.

Is this possible?

(So far i read in the docs, that you can cancel specific notifications. A simple .clearAll() call would be best)

Regards, Richard

Was it helpful?

Solution

NotificationManager has a clearAll() method that you can call

OTHER TIPS

In your MainActivity:

NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancelAll();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top