What's the best way to clear the notification number when the user clicks on the notification? I say the best way, but really I haven't found ANY way. I'm launching a built in activity when the user clicks on the notification, not something I wrote so I can't clear it that way. I've got the notification manager's flag set to clear
NotificationManager notification
.
.
.
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.number++;
nm.notify(1,notification);
But whatever I do the Notification.number keeps going up and never resets to 0.
First, press-and-hold on the persistent notification you want to remove. Another option is to swipe the notification left or right, and then tap on the cogwheel icon shown next to it. Next, tap on the switch next to Permanent to disable it, and then press Save.
Use notifications To clear one notification, swipe it left or right. To clear all notifications, scroll to the bottom of your notifications and tap Clear all.
Use the flag, FLAG_ONGOING_EVENT to make it persistent.
Notification Manager. Android allows to put notification into the titlebar of your application. The user can expand the notification bar and by selecting the notification the user can trigger another activity. Because notifications can be very annoying, the user can disable notifications for each application.
You could use an intermediary activity which is part of your app and thus can reset your variable and then start the internal activity.
So the chain would be
Notification --starts--> Intermediary Activity --starts--> Built-in activity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With