Search code examples
androidalarmmanager

AlarmManager when app closed


Simple question, I think. I have the alarm manager instantiated with some allarms set. What happen when the user close the app?

Does the alarm manager still alert me when the alarms are fired? Or the alarm manager object is destroyed with the app?

Because sometimes the alarms are fired and other times not, so I was wondering whether this was the problem.


Solution

  • The alarm manager is a system service, and it keeps running after your app is destroyed.

    The precision of the alarm might vary, depending on how you set it.

    Check the Logcat for the cases where the alarm is fired, but you don't see any effect. ( Maybe is crashing on the background? )

    EDIT: A--C is right. Another cause of missing alarms can be the fact that all alarms get wiped on reboot. You can fix this issue by setting up a BroadcastReceiver to listen the boot_completed intent, and re-set the needed alarms.