androidandroid-intentuninstallationdevice-admin

Programmatically deactivate a Device Admininstrator in Android?


Is it possible to programmatically deactivate a (third-party) Device Administrator app?

I was able to retrieve all the apps with Device Administrator activated using the DevicePolicyManager and getActiveAdmins():

final DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
final List<ComponentName> adminList = dpm.getActiveAdmins();

for ( ComponentName app : adminList ) {
    Log.d(TAG, "App: ", app.getPackageName());
}

However, in order to deactivate them, I cannot use removeActiveAdmin(...), since it won't remove a component that is not my own app.

I was thinking to use an Intent and startActivity() in order to open the Device Administrator's deactivation page of that specific component I want to deactivate. Is it possible?


Solution

  • Is it possible to programmatically deactivate a (third-party) Device Administrator app?

    No. It is not possible to programmatically activate one, either.

    I was thinking to use an Intent and startActivity() in order to open the Device Administrator's deactivation page of that specific component I want to deactivate.

    There is no entry point in the Settings app to directly go to the remove-a-device-admin screen, let alone a documented Intent action for it. You can add device administrators this way, but not remove them.