93

I wrote an app with device admin enabled (DevicePolicyManager) and installed. But when I want to uninstall it, it returns failed with this message

WARN/PackageManager(69): Not removing package com.mypackage.test: has active device admin

How can I uninstall it, or uninstall it programmically? Thanks.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
shiami
  • 7,174
  • 16
  • 53
  • 68
  • Also, if you are a user of DPC Test and having problems uninstalling it, the top answer below is useful for that purpose. – Joel Butler Jan 28 '22 at 22:03

8 Answers8

192

Go to SETTINGS->Location and Security-> Device Administrator and deselect the admin which you want to uninstall.

Now uninstall the application. If it still says you need to deactivate the application before uninstalling, you may need to Force Stop the application before uninstalling.

alexdlaird
  • 1,174
  • 12
  • 34
Atmaram
  • 3,655
  • 2
  • 27
  • 33
  • 3
    It is a bit different for me, at least on a huawei. You should go to settings->security->device administrators and then you should deactivate your app. – desmond13 Dec 14 '15 at 21:00
  • 2
    The APK (Google Play Services) does not appear on this Device Administrator list. – andreszs Mar 24 '18 at 23:47
  • 1
    I used this to guide me to Uninstalling Test DPC (you think it would be easy to find/do, but it isn't). In Android 12 (Settings->Security->Device admin apps) when I selected DPC Test and threw the admin toggle to "off" it warned me that it was going to remove all of that associated with DPC Test...which is exactly what I wanted. – Joel Butler Jan 28 '22 at 21:44
38

You could also create a new DevicePolicyManager and then use removeAdmin(adminReceiver) from an onClickListener of a button in your app

//set the onClickListener here
{
   ComponentName devAdminReceiver = new ComponentName(context, deviceAdminReceiver.class);
   DevicePolicyManager dpm = (DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE);
   dpm.removeActiveAdmin(devAdminReceiver);
}

And then you can uninstall

Reed
  • 14,703
  • 8
  • 66
  • 110
  • How can i ask for my application password before executing the remove device admin stated above ?? is there any way to that ?? – rolling.stones Jun 14 '12 at 12:07
  • 1
    There is no **legitimate** way to do it. You could include in `onDisableRequested` some code to lock device using the admin class. User then would need to unlock the phone with the password you chose (likely app password). And then to ACTUALLY disable admin, the user would need to navigate to your app and click a button in it. Of course, if you're going to prevent the user from disabling admin, it needs to be made **VERY** clear to the user that if they try to disable, their device will be locked. – Reed Jun 14 '12 at 21:11
  • **Jakar**: Note that `onDisableRequested` is called immediately after the user clicks "Disable" in the system settings. At this point, the AdminReceiver code can do something - lock the device, wipe the device, etc., but there is no way to ask the user more questions, to display any warnings, or to ask the user if they are sure. Whatever dialogs or activities you show from `onDisableRequested`, will be shown, but the user can simply dismiss them with the Back button, and then your admin WILL BE DISABLED, and your app will have accomplished nothing to prevent it. – winitzki Jun 20 '12 at 09:12
  • The above is correct for Android 3.1 and below. It seems that Android 3.2 have fixed this problem! See also http://stackoverflow.com/questions/9298364/how-to-wipe-android-device-when-device-admin-is-deactivated – winitzki Jun 20 '12 at 10:06
6

On Samsung go to "Settings" -> "Lock screen and security" -> "Other security settings" -> "Phone administrators" and deselect the admin which you want to uninstall.

The "security" word was hidden on my display, so it was not obvious that I should click on "Lock screen".

raacer
  • 5,302
  • 3
  • 27
  • 46
4

Redmi/xiaomi user

Go to "Settings" -> "Password & security" -> "Privacy" -> "Special app access" -> "Device admin apps" and select the account which you want to uninstall.

Or Simply

go to setting -> Then search for Device admin apps -> click and select the account which you want to uninstall.

Srikrushna
  • 4,366
  • 2
  • 39
  • 46
2

Enter vault password and inside vault right top corner options icon is there. Press on it. In that ->settings->vault admin rites to be unselected. Work done. U can uninstall app now.

Natendra
  • 21
  • 1
2

For Redmi users,

Settings -> Password & security -> Privacy -> Special app access -> Device admin apps

Click the deactivate the apps

Rajan
  • 111
  • 6
1

If you known the package name,with abd you can remove the device owner

adb shell dpm remove-active-admin packagename/.yourAdminReceiver

then

adb uninstall packagename
Fangxing
  • 5,716
  • 2
  • 49
  • 53
1

On a Samsung Galaxy S9 with Android 10 and One UI 2.0: Biometrics and security -> Other security settings -> Device admin apps.

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501