I have an app with AdminPolicy since Android 4.0 and worked like a charm.
Now with Android 5.0 when i start the Admin check Activity, the app don't open the Activity, but flashes white and black.
This is my code that worked in Android 4.0 ...
private void checkAdmin() {
if(!mDPM.isAdminActive(mPolicyAdmin)){
Intent activateAdminIntent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
activateAdminIntent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mPolicyAdmin);
activateAdminIntent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Policy Admin");
startActivityForResult(activateAdminIntent, REQ_ACTIVATE_ADMIN_DEVICE);
}else{
}
}
Everytime I run this code, isAdminActive return always false, because startActivityForResult doesn't start nothing...
Why?
Here the solution.
Leave in the Activity Manifest this line: