How to Re-Activate Admin Access using DevicePolicyManager

63 Views Asked by At

Using Android Policy Manager, I am asking the user to grant admin access to my app when needed (to be able to lock the screen from within my app).

When I needed, I remove this admin access using:

        devicePolicyManager.removeActiveAdmin(new ComponentName(this, DeviceAdminReceiver.class));

the problem here is that when I need admin access later in my app, the system will ask the user again to grant that access (activate). All I needed is to be able to temporarily inactivate it and then activate it when needed...given that I am granted access the first time.

Any help?

used devicePolicyManager to build an intent to ask for admin access activation. Then used devicePolicyManager.removeActiveAdmin(new ComponentName(this, DeviceAdminReceiver.class));

to deactivate it.

I need to be able to activate it again without having to ask the user

0

There are 0 best solutions below