I am using AlarmManager to periodically check for new content at some endpoint, validate if the results coming from the endpoint are the same as the ones I already have on my app, and if its not the same create a notification for each item.
What i need to know is how should i make the alarms to start only when the application is paused or stopped and cancel the alarms when de application is started or resumed.
where should i start the alarms and where should i cancel them?
In Android Notifications Guideline it says (on chapter: When not to display a notification):
Don't create a notification if the relevant new information is currently on screen. Instead, use the UI of the application itself to notify the user of new information directly in context. For instance, a chat application should not create system notifications while the user is actively chatting with another user.
If I have the application open i just want to disable alarms, when the application is closed/paused i want to cancel everything.