Heinz Heinz - 4 years ago 124
Android Question

Call method on deleting notification

I know that it's possible to call activity on deleting notification by user with

setDeleteIntent
. But I don't want to open a new activity when user deletes (swipes, dismisses) notification, I want to call a method in background, how I should to that?

Answer Source

Option 1 Use BroadcastReceiver for that purpose. Declare it in your AndroidManifest.xml and pass PendingIntent that will send broadcast to it. So you can use this call to run your function.

Option 2 Use Service or IntentService for that purpose. Again, just declare your service in AndroidManifest.xml, and set up PendingIntent accordingly. Then handle call inside service implementation in order to call your method.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download