Android Question Auto-Restore setting when app uninstalled

JohnC

Expert
Licensed User
Longtime User
Is there an intent or something that can tell my app it is being uninstalled?

I ask because my app will make a change to a user's setting on the phone (default ringtone), and I want my app to automatically restore the settings original value when my app is uninstalled.

I dont want my user to have to remember to *manually* run some "run this before you uninstal me" routine in my app before the user uninstalls my app - I want my app to automatically restore the user's original ringtone setting when they uninstall the app using the playstore or system app manager or whatever.

Any suggestions on how to do this?
 

JohnC

Expert
Licensed User
Longtime User
But the problem with that is that the user will probably not remember to use my app's uninstall and will instead use the systems/homescreen uninstaller.

Windows Mobile apps had a way to hook into the uninstall process when the user used the system uninstaller.

Wow, this surprises me because android apps are able to modify "system" settings, like the default ringtone, and without the ability to have my app "clean-up" (restore the previous/original ringtone) when its being uninstalled, that setting will become orphaned when the user uninstalls my app. Big oversight in my opinion.
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
Can you maybe use a small service (at boot) and ask the user in the service_destroy (if it gets fired?) About restoring? Not sure if it's the right way to go but just a thought to help you move forward.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Just to make sure I understand you, are you saying that I should create a small dummy service in my app, that hopefully will always be running (via "run at boot"), and when the user goes to uninstall my app, the service_destroy event will be triggered and can then prompt the user to restore the default ringtone?

If so, I can give this a try, but I hope the system/homescreen uninstaller doesn't force a kill task on the entire service and prevent my app from displaying a prompt to the user midway during the uninstall process.
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
You'll just have to experiment. I know you'll have to workaround poping a msgbox in a service. You'll also have to probably create an ongoing service with an empty notification icon, I.e. "" maybe you'll have to auto restore on the destroy (I.e. reboot) and set it back up in the create at boot?

If there's a will there's a way...
 
Upvote 0
Top