1

I currently have a notification in my Android application that has a PendingIntent so that when it is clicked an activity is opened.

I currently keep a counter for the notification, similar to the native missed calls notification.

I can reset this counter to 0 when the notification is clicked.

I also want to reset the counter to 0 when the user selects the "Clear all notifications" button. I have done a search and seen the way to do this is to use the DeleteIntent.

But I cant figure out how to use this alongside my PendingIntent, can anyone help me out?

Donal Rafferty
  • 19,469
  • 37
  • 112
  • 186
  • How do you reset the counter to 0 when the notification is clicked? I am using an int variable in SharedPreferences as my counter and can't figure out how to reset when the user clicks on the Notification dropdown shade. – AJW May 15 '18 at 03:14

1 Answers1

2

Create a broadcast or service PendingIntent, pointing to a BroadcastReceiver or IntentService that will reset your counter, and associate that PendingIntent with your Notification via deleteIntent.

CommonsWare
  • 954,112
  • 185
  • 2,315
  • 2,367