问题
I use AlarmManager
to issue local notifications to user. But if I kill my application using Settings->Apps->Stop, alarm manager seems to be destroyed and all the notification icons disappears from status bar.
It it normal? The idea of local notifications is to persuade user to start my great app if it's closed. And it seems odd for me that they are being wiped out if I kill the app.
回答1:
If you KILL your application you also kill the AlarmManager. There is nothing odd about it. You close the app by pressing the home button, not by killing it via the settings.
回答2:
Use service to set AlarmManager and notification.
Also keep in mind that once device is restarted Alarm is cancelled.
So you will need to set broadcast receiver.
look at this Click here
来源:https://stackoverflow.com/questions/13969709/android-alarmmanager-behavior-when-application-is-forced-to-close