Relative Content

Tag Archive for androidalarmmanager

Alarm manager but it should only work when the app is being used

I’ve worked with AlarmManager before but I only use it for when I want to run a code that is time specific when the app is not being used. Is there a way to create an AlarmManager that runs a code when the app is being used but it should stop when the app is closed?

Android AlarmManager fails to deliver alarm created with setExact if application is not running

As per Google documentation. https://developer.android.com/reference/android/app/AlarmManager.html “the Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running.” That is exactly my use case. I create Alarm with PendingIntent in my app setting few mins in the future, then I close the application. OS needs to deliver Intent via Broadcast and wake up my app. Application then triggers some internal function once Intent delivered to the app. All works fine if my application is running all the time:
Relevant code: