Detect if notification has been deleted

Aeefire picture Aeefire · Mar 19, 2013 · Viewed 7.5k times · Source

I have the following problem. I want to detect when a notification has been removed from the notification bar.

I can scan notifications with an AccessbilityService and casting its ParcelableData to a notification

Notification notif = (Notification) event.getParcelableData();

One thought of mine was, utilizing if the PendingIntent of the notification has been clicked, but I can't find anything on how to detect that.

Any ideas? I am kind of desperate... trying it for hours now.

Answer

Damien Belard picture Damien Belard · Nov 10, 2014

You can use a setDeleteIntent on the Notification.Builder:

http://developer.android.com/reference/android/app/Notification.Builder.html#setDeleteIntent(android.app.PendingIntent)

It can be use to do what you want (I guess it's too late for you but it can help someone else)