Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if notification has been deleted

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.

like image 240
Aeefire Avatar asked Oct 28 '25 07:10

Aeefire


2 Answers

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)

like image 115
Damien Belard Avatar answered Oct 31 '25 07:10

Damien Belard


A very similar question has already been answered here on SO:

Detect a new Android notification

In short, it's possible to detect when a new notification appears, but that's about it. You can't detect when notifications have been dismissed.

like image 35
Michell Bak Avatar answered Oct 31 '25 06:10

Michell Bak