List of usage examples for android.app.admin DevicePolicyManager getActiveAdmins
public @Nullable List<ComponentName> getActiveAdmins()
From source file:Main.java
/** * @return true if the device or profile is already owned *//*from ww w. ja va2s .c om*/ public static boolean isManaged(Context context) { DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context .getSystemService(Context.DEVICE_POLICY_SERVICE); List<ComponentName> admins = devicePolicyManager.getActiveAdmins(); if (admins == null) return false; for (ComponentName admin : admins) { String adminPackageName = admin.getPackageName(); if (devicePolicyManager.isDeviceOwnerApp(adminPackageName) || devicePolicyManager.isProfileOwnerApp(adminPackageName)) { return true; } } return false; }