Example usage for android.os UserManager getProfiles

List of usage examples for android.os UserManager getProfiles

Introduction

In this page you can find the example usage for android.os UserManager getProfiles.

Prototype

@UnsupportedAppUsage
public List<UserInfo> getProfiles(@UserIdInt int userHandle) 

Source Link

Document

Returns list of the profiles of userHandle including userHandle itself.

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 .  j a v  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;
}