有没有办法找到设备中配置的用户列表(android 4.2+)?
谢谢, Jeyanthi
答案 0 :(得分:1)
好。如果您看到UserManager.java
源代码,则可以找到这些方法。
Hovewer,这些方法需要android.permission.MANAGE_USERS
。
MANAGE_USERS
具有签名系统的保护级别,这意味着必须使用平台密钥对应用程序进行签名。
/**
* Returns information for all users on this device.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
* @return the list of users that were created.
* @hide
*/
public List<UserInfo> getUsers() {
try {
return mService.getUsers(false);
} catch (RemoteException re) {
Log.w(TAG, "Could not get user list", re);
return null;
}
}
/**
* Returns information for all users on this device.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
* @param excludeDying specify if the list should exclude users being removed.
* @return the list of users that were created.
* @hide
*/
public List<UserInfo> getUsers(boolean excludeDying) {
try {
return mService.getUsers(excludeDying);
} catch (RemoteException re) {
Log.w(TAG, "Could not get user list", re);
return null;
}
}