Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an AlarmManager alarm persist if app is killed by system due to low memory?

Tags:

android

I already know that if your app is forced closed by an app killer, or through the Android settings, your pending alarms are lost. But what if Android itself killed it due to very low memory. Would your alarms be lost in this case? How often does this actually happen?

I see two ways to recover from losing an alarm:

  1. If your app has a main activity, use onCreate() to check if your alarm is running behind schedule (alarm should store the time it last ran in a pref), and reschedule it as necessary.

  2. Find some common recurring Android task to latch onto with a receiver to do the same check as above.

Both of these have some obvious major cons. Any other ideas?

like image 959
Tenfour04 Avatar asked Apr 04 '11 22:04

Tenfour04


1 Answers

I already know that if your app is forced closed by an app killer, or through the Android settings, your pending alarms are lost.

Definitely a task killer on Android 2.1 and earlier has this effect. I am not aware that using the Settings app has this effect, though I have not tried it.

Would your alarms be lost in this case?

No.

like image 177
CommonsWare Avatar answered Nov 01 '22 04:11

CommonsWare