List of usage examples for android.app.admin DevicePolicyManager isManagedProfile
public boolean isManagedProfile(@NonNull ComponentName admin)
From source file:com.afwsamples.testdpc.common.Util.java
/** * Return {@code true} iff we are the profile owner of a managed profile. * Note that profile owner can be in primary user and secondary user too. *///w ww .ja v a2s . co m @TargetApi(VERSION_CODES.N) public static boolean isManagedProfileOwner(Context context) { final DevicePolicyManager dpm = getDevicePolicyManager(context); if (BuildCompat.isAtLeastN()) { try { return dpm.isManagedProfile(DeviceAdminReceiver.getComponentName(context)); } catch (SecurityException ex) { // This is thrown if we are neither profile owner nor device owner. return false; } } UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); return isProfileOwner(context) && userManager.getUserProfiles().size() > 1; }