-1

有没有办法找到设备中配置的用户列表(android 4.2+)?

谢谢, 杰扬蒂

4

1 回答 1

1

好。如果你看到UserManager.java源代码,你可以找到这些方法。然而,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;
        }
    }
于 2013-02-08T11:33:29.987 回答