I have a repeating AlarmManager that calls a Service to perform some background updates. I read somewhere that I need to cancel the AlarmManager in the service’s onDestroy, but this doesn’t seem to make sense to me. It seems to be me you’d only want to cancel the Alarm if you don’t want it to fire again.
I have a repeating AlarmManager that calls a Service to perform some background updates.
Share
You might want to provide a link, or a more detailed explanation/argument. You might want to
cancel background threads
onDestroy(), but alarms are independent of the activity, and will fire (and create a process if necessary) even if your activity is not running. Once you cancel it, it will be gone, so you will not get those updates. You should only cancel if you don’t need them anymore, e.g., an preferences option to cancel automatic updates to save battery, etc.