Example usage for android.os UserManager isSystemUser

List of usage examples for android.os UserManager isSystemUser

Introduction

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

Prototype

public boolean isSystemUser() 

Source Link

Document

Used to check if this process is running under the system user.

Usage

From source file:com.afwsamples.testdpc.common.Util.java

@TargetApi(VERSION_CODES.M)
public static boolean isPrimaryUser(Context context) {
    if (isAtLeastM()) {
        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
        return userManager.isSystemUser();
    } else {/*  w w  w .  j  a  va2  s . co m*/
        // Assume only DO can be primary user. This is not perfect but the cases in which it is
        // wrong are uncommon and require adb to set up.
        return isDeviceOwner(context);
    }
}