Take the 2-minute tour ×  I have an android application, that
runs a standalone service. Now, I do set some alarms in my
service. I want to cancel all these alarms when my application
gets uninstalled.  I tried putting code for cancelling all
alarms in OnDestroy() but it is not guaranteed to be called. Is
there any reliable way to cancel all alarms when application is
unistalled ?  share|improve this question  2 Answers 2  up vote
1 down vote accepted  If your app is uninstalled there will be
nothing to handle the PendingIntent of the alarms you set. So
they will be broadcast but no one will handle them and the
system remove them. If you're concerned about different versions
of your app handling the alarm differently after being
reinstalled add a version extra to your pending intent.
share|improve this answer  There is no way to run code on
uninstall unfortunately. I would say onDestroy() is likely to be
called on uninstall as the service will be finalized if it is
running at the time. One thing I do not kno