小编Zou*_*uBi的帖子

Android - 获取用户列表和个人资料名称

我们可以在 Android 设备上创建多个用户和配置文件,例如,有一个主用户,我还设置了一个名为“工作配置文件”的工作配置文件。

使用以下 adb 命令:

adb shell pm list users
Run Code Online (Sandbox Code Playgroud)

我得到这个结果:

UserInfo{0:My User:13} 正在运行 UserInfo{10:Work Profile:30} 正在运行

很好,我可以看到我的用户信息,上面有名称工作资料。现在,我想从我的应用程序中获取此列表。

我尝试使用此代码:

for(Account account: AccountManager.get(this).getAccounts()) {
        DebugLog.e("COUCOU " + account.name + " " + account.toString());
    }
Run Code Online (Sandbox Code Playgroud)

但工作资料帐户未出现在列表中。只有主要用户...知道如何获得与 ADB shell 命令相同的列表吗?

android user-profile profile-owner

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

profile-owner ×1

user-profile ×1