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?
Now, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With