Since: API level 6
public class

MultiUserManager

extends Object
java.lang.Object
   ↳ com.samsung.android.knox.multiuser.MultiUserManager

Class Overview

This class provides APIs for managing multiple user capability on device. Client administrator will be able to turn on/off such functionality, create/remove users, allow/prevent additional users from being created or removed, among other utility methods.

Since
API level 6
MDM 4.0

Summary

Public Methods
boolean allowMultipleUsers(boolean allow)
Deprecated in API level 35
boolean allowUserCreation(boolean allow)
Deprecated in API level 35
boolean allowUserRemoval(boolean allow)
Deprecated in API level 35
int createUser(String name)
Deprecated in API level 35
int[] getUsers()
Deprecated in API level 35
boolean isUserCreationAllowed()
Deprecated in API level 35
boolean isUserRemovalAllowed()
Deprecated in API level 35
boolean multipleUsersAllowed()
Deprecated in API level 35
boolean multipleUsersSupported()
Deprecated in API level 35
boolean removeUser(int userId)
Deprecated in API level 35
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean allowMultipleUsers (boolean allow)

Since: API level 6

Deprecated in API level 35

API to enable or disable multiple users from using the device.

Returns
  • true if success, otherwise false.
Throws
SecurityException If caller does not have required permissions
UnsupportedOperationException If device does not support this feature
Usage
Administrator can disable multiple user support without any user interaction. User or 3rd party applications cannot enable multiple user support once disabled.

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_MULTI_USER_MGMT" permission which has a protection level of signature.
Since
API level 6
MDM 4.0
Multiuser Environment
Global Scope

public boolean allowUserCreation (boolean allow)

Since: API level 9

Deprecated in API level 35

API to allow or block user creation on device.

Parameters
allow true to enable user creation, false to block it.
Returns
  • true if configuration was successfully saved, otherwise false.
Throws
SecurityException If caller does not have required permissions
UnsupportedOperationException if device doesn't have multiple users support.
Usage
Administrator can prevent the user and other Administrators from creating more user accounts onto device. User accounts previously created will remain intact.

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_MULTI_USER_MGMT" permission which has a protection level of signature.
Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope

public boolean allowUserRemoval (boolean allow)

Since: API level 9

Deprecated in API level 35

API to allow or block user removal from device.

Parameters
allow true to enable user removal, false to block it.
Returns
  • true if configuration was successfully saved, otherwise false.
Throws
SecurityException If caller does not have required permissions
UnsupportedOperationException if device doesn't have multiple users support.
Usage
Administrator can prevent the user and other Administrators from removing existing user accounts from device.

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_MULTI_USER_MGMT" permission which has a protection level of signature.
Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope

public int createUser (String name)

Since: API level 9

Deprecated in API level 35

API to create a guest user on device.

Parameters
name Guest user name.
Returns
  • user ID if creation was successful, otherwise -1.
Throws
SecurityException If caller does not have required permissions
UnsupportedOperationException if device doesn't have multiple users support.
Usage
Administrator can create a guest user with the given name. There can be only one guest user on device, so this API fails if a guest user already exists.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 MultiUserManager muMgr = edm.getMultiUserManager();
 try {
     int userId = muMgr.createUser("Mary");
     if(userId > 0) {
         // Guest user "Mary" was successfully created.
     } else {
         // Guest user creation failed.
     }
 } catch (UnsupportedOperationException ex) {
     Log.w(TAG, "UnsupportedOperationException: " + ex.getMessage());
 } catch (SecurityException ex2) {
     Log.w(TAG, "SecurityException: " + ex2.getMessage());
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_MULTI_USER_MGMT" permission which has a protection level of signature.
Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope

public int[] getUsers ()

Since: API level 9

Deprecated in API level 35

API to retrieve all users created on device.

Returns
  • a list of IDs of installed users or null if the operation fails.
Throws
UnsupportedOperationException if device doesn't have multiple users support.
SecurityException If caller does not have required permissions
Usage
Administrator can obtain the list of all users currently installed on device.

Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_MULTI_USER_MGMT" permission which has a protection level of signature.
Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope

public boolean isUserCreationAllowed ()

Since: API level 9

Deprecated in API level 35

Returns whether user creation is allowed or blocked.

Returns
  • true if user creation is allowed, false if blocked.
Usage
Administrator can verify if user creation is allowed.

Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope

public boolean isUserRemovalAllowed ()

Since: API level 9

Deprecated in API level 35

Returns whether user removal is allowed or blocked.

Returns
  • true if user removal is allowed, false if blocked.
Throws
UnsupportedOperationException if device doesn't have multiple users support.
Usage
Administrator can verify if user removal is allowed.

Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope

public boolean multipleUsersAllowed ()

Since: API level 6

Deprecated in API level 35

API to check whether multiple user support is allowed.

Returns
  • true if multiple user is allowed, otherwise false.
Throws
UnsupportedOperationException If device does not support this feature
Since
API level 6
MDM 4.0
Multiuser Environment
Global Scope

public boolean multipleUsersSupported ()

Since: API level 6

Deprecated in API level 35

API to check whether multiple users are supported on the device.

Returns
  • true if multiple user is supported, otherwise false.
Since
API level 6
MDM 4.0
Multiuser Environment
Global Scope

public boolean removeUser (int userId)

Since: API level 9

Deprecated in API level 35

API to remove a user from device.

Parameters
userId ID of the user to be removed.
Returns
  • true if the user was successfully removed, otherwise false.
Throws
SecurityException If caller does not have required permissions
UnsupportedOperationException if device doesn't have multiple users support.
Usage
Administrator can remove an existing user by providing its user ID. If there isn't any user associated with the given ID or if the provided ID refers to the owner account, this operation will fail.

 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 MultiUserManager muMgr = edm.getMultiUserManager();
 //integer "userId" refers to a previously created user.
 try {
     boolean result = muMgr.removeUser(userId);
     if(result) {
         // User whose ID is "userId" was successfully removed from device.
     } else {
         // User removal failed.
     }
 } catch (UnsupportedOperationException ex) {
     Log.w(TAG, "UnsupportedOperationException: " + ex.getMessage());
 } catch (SecurityException ex2) {
     Log.w(TAG, "SecurityException: " + ex2.getMessage());
 }
 
Permission
The use of this API requires the caller to have the "com.samsung.android.knox.permission.KNOX_MULTI_USER_MGMT" permission which has a protection level of signature.
Since
API level 9
MDM 4.1
Multiuser Environment
Global Scope