Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Require a password to uninstall/remove application

Tags:

I would like to require that a user type a password before being allowed to uninstall/remove my application. How can I implement this functionality?

like image 609
arams Avatar asked Aug 03 '09 10:08

arams


People also ask

How do I lock an app to uninstall?

Use AppLock If you want to prevent other users from uninstalling your apps, launch AppLock, go to Privacy, and under Advanced, lock the Settings app. In this manner, users will need to use the authentication method you previously set to open the Settings app.

How do I create a password to uninstall?

Tap on the System Lock tab and toggle the Install/Uninstall switch to "on." Doing so will require a passcode in order for App Lock to be uninstalled.


2 Answers

You could do this by:

  • The first time your app is installed, install a separate application/package ("watcher").
  • The only classes "watcher" contains is a BroadcastReceiver that listens for ACTION_PACKAGE_REMOVED
  • Add a BroadcastReceiver to your application that also listens for ACTION_PACKAGE_REMOVED
  • When a intent is broadcast to one of your receivers, check if the other component is still installed. If is isn't (the user just uninstalled it), prompt for the password - if it's wrong, reinstall the other component. If it's right, uninstall yourself.
like image 57
Isaac Waller Avatar answered Oct 11 '22 11:10

Isaac Waller


You can exec logcat and get the start activity intent information. You will find that before the uninstall activity is displayed, there is a text msg such as: Starting activity: Intent { act=android.intent.action.DELETE dat=package:com.comodo.pimsecure cmp=com.android.packageinstaller/.UninstallerActivity } then you can pop a activity ask for password now.

like image 38
Mikonos Avatar answered Oct 11 '22 10:10

Mikonos