How to reset notification number for notification

What is the best way to delete a notification number when a user clicks on a notification? I say the best way, but in fact I have not found ANY way. I start the inline activity when the user clicks on the notification, and not what I wrote, so I can’t figure it out. I have the notification manager flag set

NotificationManager notification . . . notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.number++; nm.notify(1,notification); 

But no matter what I do, the Notification.number number continues to grow and never resets to 0.

+6
android notifications
source share
2 answers

You can use mediation, which is part of your application, and therefore, can reset your variable and then start internal activity.

So the chain will be

Notification - Starts β†’ Intermediate Activity - Starts β†’ Built-in Activity

+2
source share

I use a combination of what @CommonsWare recommends and extends the application object, as here How to update the notification number .

Edit: Further testing shows that this actually does not work, because the BroadcastReceiver is called for each notification and because it reset the number on each notification, the number is never true.

0
source share

All Articles