How to get android phone user's google account name?

后端 未结 2 1025
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 04:00

So I am making mobile game with unity engine, think to release to android target.

Now my game will have my own custom highscore board, there I think when user earn score

2条回答
  •  忘掉有多难
    2021-01-25 04:16

    try this

    AccountManager manager = AccountManager.get(context);
    Account[] accounts = manager.getAccountsByType("com.google");
    List username = new LinkedList();
    
    for (Account account : accounts) {
        username.add(account.name);
    }
    

    and add permission to android manifest

    
    

提交回复
热议问题