public class UserManager extends Object
Constructor and Description |
---|
UserManager(Context context,
IUserManager service) |
Modifier and Type | Method and Description |
---|---|
UserInfo |
createUser(String name,
int flags)
Creates a user with the specified name and options.
|
static int |
getMaxSupportedUsers()
Returns the maximum number of users that can be created on this device.
|
long |
getSerialNumberForUser(UserHandle user)
Return the serial number for a user.
|
int |
getUserCount()
Return the number of users currently created on the device.
|
UserHandle |
getUserForSerialNumber(long serialNumber)
Return the user associated with a serial number previously
returned by
getSerialNumberForUser(UserHandle) . |
int |
getUserHandle()
Returns the user handle for the user that this application is running for.
|
int |
getUserHandle(int userSerialNumber)
Returns a userHandle on this device for a given user serial number.
|
Bitmap |
getUserIcon(int userHandle)
Returns a file descriptor for the user's photo.
|
UserInfo |
getUserInfo(int userHandle)
Returns the UserInfo object describing a specific user.
|
String |
getUserName()
Returns the user name of the user making this call.
|
List<UserInfo> |
getUsers()
Returns information for all users on this device.
|
List<UserInfo> |
getUsers(boolean excludeDying)
Returns information for all users on this device.
|
int |
getUserSerialNumber(int userHandle)
Returns a serial number on this device for a given userHandle.
|
boolean |
isGuestEnabled()
Checks if a guest user is enabled for this device.
|
boolean |
isUserAGoat()
Used to determine whether the user making this call is subject to
teleportations.
|
boolean |
isUserRunning(UserHandle user)
Return whether the given user is actively running.
|
boolean |
isUserRunningOrStopping(UserHandle user)
Return whether the given user is actively running or stopping.
|
boolean |
removeUser(int userHandle)
Removes a user and all associated data.
|
void |
setGuestEnabled(boolean enable)
Enable or disable the use of a guest account.
|
void |
setUserIcon(int userHandle,
Bitmap icon)
Sets the user's photo.
|
void |
setUserName(int userHandle,
String name)
Updates the user's name.
|
static boolean |
supportsMultipleUsers()
Returns whether the system supports multiple users.
|
void |
wipeUser(int userHandle)
Wipes all the data for a user, but doesn't remove the user.
|
public UserManager(Context context, IUserManager service)
public static boolean supportsMultipleUsers()
public int getUserHandle()
public String getUserName()
public boolean isUserAGoat()
public boolean isUserRunning(UserHandle user)
user
- The user to retrieve the running state for.public boolean isUserRunningOrStopping(UserHandle user)
isUserRunning(UserHandle)
, but will also return
true if the user had been running but is in the process of being stopped
(but is not yet fully stopped, and still running some code).user
- The user to retrieve the running state for.public UserInfo getUserInfo(int userHandle)
android.Manifest.permission#MANAGE_USERS
permission.userHandle
- the user handle of the user whose information is being requested.public long getSerialNumberForUser(UserHandle user)
user
- The user whose serial number is to be retrieved.getUserForSerialNumber(long)
public UserHandle getUserForSerialNumber(long serialNumber)
getSerialNumberForUser(UserHandle)
.serialNumber
- The serial number of the user that is being
retrieved.getSerialNumberForUser(UserHandle)
public UserInfo createUser(String name, int flags)
android.Manifest.permission#MANAGE_USERS
permission.name
- the user's nameflags
- flags that identify the type of user and other properties.UserInfo
public int getUserCount()
public List<UserInfo> getUsers()
android.Manifest.permission#MANAGE_USERS
permission.public List<UserInfo> getUsers(boolean excludeDying)
android.Manifest.permission#MANAGE_USERS
permission.excludeDying
- specify if the list should exclude users being removed.public boolean removeUser(int userHandle)
android.Manifest.permission#MANAGE_USERS
permission.userHandle
- the integer handle of the user, where 0 is the primary user.public void setUserName(int userHandle, String name)
android.Manifest.permission#MANAGE_USERS
permission.userHandle
- the user's integer handlename
- the new name for the userpublic void setUserIcon(int userHandle, Bitmap icon)
userHandle
- the user for whom to change the photo.icon
- the bitmap to set as the photo.public Bitmap getUserIcon(int userHandle)
userHandle
- the user whose photo we want to read.Bitmap
of the user's photo, or null if there's no photo.public void setGuestEnabled(boolean enable)
android.Manifest.permission#MANAGE_USERS
permission.enable
- whether to enable a guest account.public boolean isGuestEnabled()
android.Manifest.permission#MANAGE_USERS
permission.public void wipeUser(int userHandle)
android.Manifest.permission#MANAGE_USERS
permission.userHandle
- public static int getMaxSupportedUsers()
public int getUserSerialNumber(int userHandle)
userHandle
- public int getUserHandle(int userSerialNumber)
userSerialNumber
-