Example usage for android.content.pm UserInfo isManagedProfile

List of usage examples for android.content.pm UserInfo isManagedProfile

Introduction

In this page you can find the example usage for android.content.pm UserInfo isManagedProfile.

Prototype

@UnsupportedAppUsage
    public boolean isManagedProfile() 

Source Link

Usage

From source file:com.android.managedprovisioning.ProfileOwnerPreProvisioningActivity.java

/**
 * @return The User id of an already existing managed profile or -1 if none
 * exists//from  w w w  .  jav  a2  s  .  c  o  m
 */
int alreadyHasManagedProfile() {
    UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
    List<UserInfo> profiles = userManager.getProfiles(getUserId());
    for (UserInfo userInfo : profiles) {
        if (userInfo.isManagedProfile()) {
            return userInfo.getUserHandle().getIdentifier();
        }
    }
    return -1;
}