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:
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.
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.
精彩评论