开发者

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

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 h开发者_如何学运维ave some obvious major cons. Any other ideas?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜