androidmobilenotificationsnotificationmanager

Is it possible to cancel all notifications that have a certain tag?


I'm making an android app and I would like to cancel all notifications that have a certain tag.

Right now it only seems possible to cancel notifications by their id (int id) or by both their ids and tags.

mNotificationManager.cancel(int id);

or

mNotificationManager.cancel(String tag, int id);

I want to be able to cancel all notifications of String tag regardless of int id.

Is this possible?


Solution

  • No, it isn't. The way Notification is set up, id is the primary key. You can add a subkey with tag, and cancel an individual (tag, id) pair that way, but you can't cancel based on tag alone. Really I'm not sure why they added a tag parameter, as it seems rather redundnt, except that possibly a string parameter makes for easier debugging.