问题
I'm a newbie in android so please bear with me. My Main activity creates and alarm in the alarm manager which supposed to fire in specific time, my main Activity also create Broadcast receiver which suppose to receive the Intent that the alarm fired, everything is working good until Task manager killing my App. I've check the PendingIntent list in the AlarmManager and verify that my alarm is getting erased from the Alarm Manager, I try to add service and register alarm from the service, I've red that maybe because my IntentFilter of the Broadcast receiver is defined in code and not in manifest it get killed after app process is killed, and I'm stuck on this issue for two weeks :-(, with big confuse, my design is wrong ?
Here is my needs:
- That the alarm will be very reliable, even if app is killed or even if phone is restart.
- Same goes to the broadcast receiver.
Thank you in advance,
回答1:
If the user task-kills or force-stops your application, your alarms are unregistered. And, on Android 3.1+, nothing of your app will run again until the user manually launches one of your activities.
There is nothing that you can do about this, other than to do your best to write a high-quality application that the user will have no need or wish to force-stop.
来源:https://stackoverflow.com/questions/10249492/alarm-in-the-alarmmanager-get-erased-when-process-is-killed