I don’t know if this can be done but I have a scheduler/diary app that allows the user to add/remove items. When the user adds an item, they are given an option to set a notification for either 1 hour, 30 mins, or 15 mins before the event time or else to not be notified. I am using an alarm manager with a broadcast receiver to handle this.
I want to display an option in the app menu to enable/disable notifications; i.e. if an alarm is scheduled to sound in 15 mins it should not happen. How can I implement this?
Take a look at NotificationManager class. When you set your notification you can provide a notification id like this:
If you later want to cancel this notification(i.e. like in your case, if a user has selected an option to disable notifications) you would need to use
Or you could use cancelAll() to cancel all notifications:
Let me know if this helps.