I'm developing an application for parents to watch out for their children. So this application cannot be removed by the child. I need to know how to make it uninstallable or the user need password to remove that application.
-
2Do you see any good reasons for this type of functionality not existing unless the device is rooted? – Jon Sep 24 '11 at 15:42
-
3Just to expand on Jon's comment, in case you missed his point, if this functionality existed it would be a ***very*** bad thing. – Perception Sep 24 '11 at 15:45
-
1@jon , & perception i do know that this is very bad but this is what client requires, i can't argue with him and i already told him off the records that if that much restriction needed then why you are giving cell phone to your children. – Ankur Mistry Sep 24 '11 at 16:12
-
i guess this link gives all the answers those says that it is not possible many thanks to @willytate http://developer.android.com/guide/topics/admin/device-admin.html – Ankur Mistry Sep 24 '11 at 16:58
-
as i've got the solution, i will post the code once it is done, im sure it does help many – Ankur Mistry Sep 24 '11 at 17:03
-
@AnkurMistry.. you got any success ?? if YES then kindly share it with me. – Noman Feb 24 '14 at 10:10
-
@AnkurMistry - any success??? please share your code – Balwinder SIngh Dec 10 '14 at 12:08
2 Answers
Ankur,
I think the closest thing to what your looking for is the Device Administration feature introduced in 2.2.
Once the application is registered as a Device Administrator, it can't be uninstalled unless its unregistered. This will prevent the app from being uninstalled.
While the Device Admin API doesn't allow for password protection of this particular feature, you can password protect your application to prevent someone from tampering with the Device Admin features in the app.
I use an app called SeekDroid that has a similar functionality.

- 33,439
- 9
- 77
- 71
-
@WILLTATE : this input is a great headstart !! Just need a some more information 1> MY APP IS DEVICE ADMIN NOW AND CANNOT BE UNINSTALLED 2> HOW CAN I ASK FOR PASSWORD WHEN USER DISABLED DEVICE ADMIN 3> CAN I CALL MY APP ACTIVITY FOR THIS ?? – rolling.stones Jun 16 '12 at 11:14
-
1@willtate: "You can protect the unregister feature in your app with a password" -- no, you cannot. – CommonsWare Jun 16 '12 at 15:04
-
@CommonsWare So I can correct my answer properly. Do you mean to say it is impossible to wrap some type of password protection around the unregister feature in code, or it shouldn't be done ethically? – Will Tate Jun 17 '12 at 18:29
-
2@willtate: The device admin APIs provide a hook for you to supply an explanatory message, advising the user of why they should not unregister the device admin. The device admin APIs do not provide a hook for you to block the unregister operation. – CommonsWare Jun 17 '12 at 18:32
-
1The problem with this approach is that users will still have the option of removing the app by unregistering it from the device admin. At this point I don't think there is any solution that truly prevents apps from being uninstalled – Jaime Botero Jul 20 '12 at 13:30
-
@JaimeBotero if there is no way for the user to uninstall an application, you're probably doing something unethical! I'm wondering though, if this enable/disable is behind a password screen, could the user unregister from outside the application? Anyone know? – ingh.am Sep 13 '12 at 22:45
-
Can the Device Admin API be used to prevent a user from forcing an app to stop? – gonzobrains Jun 11 '13 at 01:15
-
Turns out this does work in 4.4. During uninstall android says can't uninstall because it's a device admin, but then presents a button to manage device admins allowing you to easily unselect it as a device admin and therefore allowing the uninstall. Haven't found a way to prevent that. – David Feb 13 '14 at 02:15
-
There is an app called Applock on google play that seems to install another device admin app that works in tandem with the main app to show a password screen when you try to unregister the app as device admin. Not sure how they are doing that though. Perhaps just watching for an activity starting and killing the device manager app if the password is not entered?? – Chris.D Sep 18 '14 at 12:50
-
1As for the ethical issue this is often a requirement for enterprise installations of compliance software (for example) where the user does not own the handset or is BYOD. There are other ways specific to manufacturers (e.g. Samsung) where they allow you to sign as a system app if you are a dev partner – Chris.D Sep 18 '14 at 12:55
I've only seen one app that does this, its called Prey and is used to track lost phones and computers. The project is open source so you could go through their code and see how they do it or contact the developer and maybe they'll tell you how they do it.

- 20,123
- 10
- 60
- 89
-
1I've looked at their code and they do exactly what William Tate's answer explains! – ingh.am Sep 13 '12 at 22:46
-
1I, too, have seen Prey do this. I don't think it is unethical at all if you allow the user to control this feature via a password. This way unauthorized people who gain access to the device cannot uninstall sensitive apps. – gonzobrains Jun 11 '13 at 01:16
-
1Prey can still be unregistred through system settings->security-device managers option – Chris.D Sep 18 '14 at 12:51