24

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?

Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
arams
  • 2,201
  • 5
  • 21
  • 18
  • 1
    could you give some more detail. OS, languages, etc. – Preet Sangha Aug 03 '09 at 10:16
  • In android, when install a application it should ask username & password. and when uninstalling the application user should enter the correct user name and password. – arams Aug 03 '09 at 10:24
  • 17
    Is that not a little harsh? As a customer, if I ever had to enter a password to uninstall a piece of software I would be very p*ssed off! I'd save yourself the bother and not implement it. – Steg Aug 03 '09 at 10:29
  • 2
    asking if it is possible is a bad question. The better question would be why would you want to do this? – Michael Brown Aug 03 '09 at 11:28
  • 20
    A parent may want to install an app to monitor their child's phone usage. The parent wouldn't want the child to be able to remove the app. – Scott Apr 23 '10 at 01:22
  • there is a sandbox application for android, when activated only some selected programs are shown in the list, and it totally prevents installing and uninstalling. activating/deactivating ofc. requires password. – guness Jan 28 '13 at 08:25
  • Examine the device every night. If the app is gone, the kid loses it for a week. Next time for a month. They'll soon learn not to screw around with the oldies :-) – paxdiablo Apr 02 '15 at 06:34

5 Answers5

14

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.
Isaac Waller
  • 32,709
  • 29
  • 96
  • 107
4

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.

Mikonos
  • 161
  • 6
  • 1
    That is one very good option to be done... but can u help with little code or some kind of help which elaborates this... MY Application is the device admin , now i want to show a password page of my application before allowing the deletion. I NEED HELP TO DETECT THE UNINSTALL ACTIVITY THE APPLICATION – rolling.stones Jun 14 '12 at 12:19
  • 1
    logcat -d -n 5 ActivityManager:I *:S and all of the log about activityManager will displayed. then you can read the log to find the key word “android.intent.action.DELETE", if you found that, then is step 2: find your package name in the same log record. if you find your package name, then this log is meaning that the device has pop a activity to uninstall your app, and you can pop a password activity now. – Mikonos Aug 23 '12 at 08:52
2

It is possible. you can do it with DeviceAdminReceiver api. (i don't no how)

Ivan Ferić
  • 4,725
  • 11
  • 37
  • 47
Sujith S Manjavana
  • 1,417
  • 6
  • 33
  • 60
1

This is a hard problem. I can think of at least one non-evil use-case for it.

e.g. Stolen Phone Recovery app - you wish to deter ne'er-do-wells from uninstalling the app.

In this case, I can think of two sensible assumptions which would stop me implementing what you're looking for:

  • the thief is unaware of your app, so will not try to uninstall it.
  • the thief is aware of your app, and switch it off until he can get it to an iron box* to re-install the OS.

* For the uninitiated: an iron box will prevent the device sending or receiving electromagnetic signals.

Of course, this answer amounts to You Ain't Going To Need It, though I suspect you have already thought this through.

jamesh
  • 19,863
  • 14
  • 56
  • 96
0

Protect installing/uninstalling apps by password makes Android more secure from malware/viruses. Your Android become as secure as iPhone.

How it works:

  1. Automatic apps installing is prompted to user. You can search the app name. If not secure, Block it.

  2. Root access is prompted to user. Too many ads is an indicator that access is dangerous.