I found a solution: if isProfileOwnerApp returns true for a single package name, this means that your application (badged) is running on a working profile. if your application runs in normal mode (no icon) isProfileOwnerApp returns false for all administrators, even if there is a working profile.
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); List<ComponentName> activeAdmins = devicePolicyManager.getActiveAdmins(); if (activeAdmins != null){ for (ComponentName admin : activeAdmins){ String packageName= admin.getPackageName(); Log.d(TAG, "admin:"+packageName); Log.d(TAG, "profile:"+ devicePolicyManager.isProfileOwnerApp(packageName)); Log.d(TAG, "device:"+ devicePolicyManager.isDeviceOwnerApp(packageName)); } }
source share