Android Question programmable alarm from a background app

engvidal

Member
Licensed User
Longtime User
I have an app that stay in background, receiving periodical firebase messages (interval of 10 minutes).
Today if the message contains a certain value, it generates a notification that plays a sound.
IT RUNS OK.

I need to start a timer (lets say 15 minutes) that will be cleared/restarted with each message received, BUT that will start a notification if the time is lapsed, indicating that there is at least 1 message lost.

Thanks in advance.

Vidal
 

JohnC

Expert
Licensed User
Longtime User
When each push notification comes in, you would invoke a "StartServiceAt" specifying a time that would be later then the next expected push notification should arrive. And when the next push notification comes in, you will specify another StartServiceAt time in the future (which clears the previous set time), and so on.

So, if the push notifications keep coming in, the StartServiceAt time should never trigger. But if the service does start, then that means a push notification didn't come in in time.

NOTE: The StartServiceAt may not run exactly at the time you specify, so just keep this in mind.
 
Last edited:
Upvote 0
Top