How to remove an app with active device admin enabled on Android?

前端 未结 6 2236
天命终不由人
天命终不由人 2020-12-12 19:55

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

WAR

6条回答
  •  长情又很酷
    2020-12-12 20:46

    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

提交回复
热议问题