arams
arams

Reputation: 2301

Require a password to uninstall/remove application

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?

Upvotes: 24

Views: 32138

Answers (5)

kutu kepik
kutu kepik

Reputation: 1

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.

Upvotes: 0

Sujith S Manjavana
Sujith S Manjavana

Reputation: 1576

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

Upvotes: 2

Mikonos
Mikonos

Reputation: 159

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.

Upvotes: 4

Isaac Waller
Isaac Waller

Reputation: 32730

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.

Upvotes: 14

jamesh
jamesh

Reputation: 20091

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.

Upvotes: 1

Related Questions