-
-
Save RamitPahwa/060393cf7b393de9f9fd870925d19006 to your computer and use it in GitHub Desktop.
For medium article on Android Enterprise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isAFWManagedApp(Context context) | |
{ | |
boolean isAFWManaged = false; | |
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); | |
List<ComponentName> activeAdmins = devicePolicyManager.getActiveAdmins(); | |
if (activeAdmins != null) | |
{ | |
for (ComponentName admin : activeAdmins) | |
{ | |
String packageName= admin.getPackageName(); | |
isAFWManaged = devicePolicyManager.isProfileOwnerApp(packageName); | |
if (isAFWManaged) | |
{ | |
break; | |
} | |
} | |
} | |
return isAFWManaged; | |
} | |
public boolean isAFWManagedDevice(Context context) | |
{ | |
boolean isAFWManaged = false; | |
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); | |
isAFWManaged = devicePolicyManager.isDeviceOwnerApp(context.getPackageName()); | |
return isAFWManaged; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment