-1

I an making security application, in which I have to do stop the application from uninstallation ,once it is install in device, have anyone do it before.

parmil86
  • 83
  • 9
  • 1
    Hmmm, looks like a duplicate to me: http://stackoverflow.com/questions/4477206/stop-uninstallation-of-application – Ocaso Protal May 13 '11 at 06:44
  • possible duplicate of [Detect if an app was uninstalled](http://stackoverflow.com/questions/2680758/detect-if-an-app-was-uninstalled) – Wesley Wiser Apr 15 '13 at 13:12

1 Answers1

0

The following solution will not let the application to uninstall, unless the user explicitly un-checks the permission from the Admin settings of the device.

Use DeviceAdminReceiver class to get that functionality, extend your class say DeviceAdminSample from DeviceAdminReceiver. Also remember to add following in your manifest.xml

<receiver android:name=".DeviceAdminSample" android:label="My App Admin"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data android:name="android.app.device_admin"
            android:resource="@xml/device_admin_sample" />
        <intent-filter>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
        </intent-filter>
    </receiver>

Add this in xml folder of your res folder

<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
    <force-lock />
</uses-policies>

Hope that helps. There might be other solution as well.

Omar Rehman
  • 2,045
  • 17
  • 17