Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing code when Application is updated/reinstalled

Tags:

android

I have Some Alarms set via AlarmManager to do some periodic jobs. I set/reset them when user opens the app for the first time & on every boot_complete event. But when the app is reinstalled via ADB then my alarms do not fire anymore. looks like the OS deletes the Alarms on reinstall of the app. I assume this will happen if the user updates the app from the market also.

If I can receive a broadcast or some sort of callback in the event of reinstall/upgrade etc of my application, I can set the alarms again. but i don't know if it is possible or how? Can someone please help me out.

like image 238
Rahul Avatar asked Jan 27 '10 00:01

Rahul


1 Answers

Yes, this is possible.

You can create a broadcast receiver that listens for any PACKAGE_* events the system sends, but you won't receive them for your own application except for when your application is being upgraded — you'll get PACKAGE_REMOVED followed soon after by PACKAGE_REPLACED.

like image 179
Christopher Orr Avatar answered Nov 15 '22 07:11

Christopher Orr