Android - How to programmatically switch users by user name?

后端 未结 2 1448
轮回少年
轮回少年 2021-01-14 15:04

I\'m new to Android and I have to do an application at work that performs the following task:

  1. I listen to a socket that is supposed to send me a user name.
2条回答
  •  独厮守ぢ
    2021-01-14 15:30

    Did you manage to get the user names once you become the device owner ? getUserProfiles and getSecondaryUsers can be used, but they both return UserHandle. I can't get the user name registered at creation. It seems that the only way is to add the MANAGE_USERS permission to the manifest but that supposes the app to be a system app : https://developer.android.com/reference/android/os/UserManager#getUserName()

    I think I will create a persistent list somewhere.

提交回复
热议问题