Skip to content

Instantly share code, notes, and snippets.

@RamitPahwa
Created Jul 27, 2021
Embed
What would you like to do?
For medium article on Android Enterprise
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