Thanks to TasKiller
I have reliable way to shutdown updates coming to my AppWidget
from the AlarmManager
! Now, sarcasm aside, how do I recover from such event? So far I only see that the Alerts
are resurrected only after rebooting the phone. I can stick recovery code into few places such as various Activity#onCreate
that belong to my app and my widget but is there a better way? Also what if the alerts are OK - is there a way to detect that and not run AlarmManager#setRepeating? Or is there a harm to run it multiple times?
views:
362answers:
1Now, sarcasm aside, how do I recover from such event?
I have heard that single-malt Scotch helps.
So far I only see that the Alerts are resurrected only after rebooting the phone.
That is only if you are hooking the BOOT_COMPLETED
broadcast Intent
and re-establishing the alarms.
Task killers are remarkably thorough, but they cannot stop a BroadcastReceiver
from receiving system broadcasts, like BOOT_COMPLETED
. You are welcome to find some other broadcast that you would like to receive to help regain control and re-establish your alarms.
Also what if the alerts are OK - is there a way to detect that and not run AlarmManager#setRepeating? Or is there a harm to run it multiple times?
You can cancel()
an existing alarm. So, if you are concerned about possible duplicates, cancel()
the current alarm (which hopefully fails quietly if the alarm does not exist), then set the alarm.