Reputation: 2767
I have an app that adds alarms to the alarm manager. When I force close/kill the app via a task killer, the alarms seem to die too.. I thought they were independent? I also have an alarm that regularly checks that my app service is always on... this seems to die together with the app too.
is this the normal behaviour?
Upvotes: 0
Views: 760
Reputation: 2309
Yes, any alarms for the process will be cancelled.
@CommonsWare explains this better than I can in this answer. He also proposes a viable though not ideal solution:
Maintain a record of when your alarm last occurred (e.g., in SharedPreferences). When your code runs (e.g., LAUNCHER activity is started), check the last-alarm time. If it was a long time ago, you know that your alarms were cleared, and so you need to reschedule them.
Upvotes: 0
Reputation: 93678
When you force close a task, it enters the stopped state. No services or broadcasts are allowed to run until an activity is run again. This is the same state as an app that's just downloaded is put into, where no services or broadcasts work until the user launches an activity in it.
Upvotes: 2