how to get firstname and lastname of Android phone owner?

前端 未结 3 1986
执笔经年
执笔经年 2020-12-29 13:34

Is there a way to get the firstname and lastname of Android phone owner? I\'ve search the internet but I have no luck. I stumbled upon this question in Stackoverlow but this

3条回答
  •  离开以前
    2020-12-29 14:40

    Try this:

    final AccountManager manager = AccountManager.get(this);
    final Account[] accounts = manager.getAccountsByType("com.google");
    final int size = accounts.length;
    String[] names = new String[size];
    for (int i = 0; i < size; i++) {
      names[i] = accounts[i].name;
    }
    

提交回复
热议问题