如何从Android联系人获取以下字段?我使用的是Android 2.2.
我想预先填充我的应用程序中的一些字段,以帮助用户在我的应用程序中订阅服务时.
那么我如何获得设备所有者的名字和姓氏.我想使用与Google帐户绑定的默认信息; 到目前为止我得到了这个:
AccountManager am = AccountManager.get(this);
Account[] accounts = am.getAccounts();
for (Account account : accounts) {
if (account.type.compareTo("com.google") == 0)
{
String possibleEmail = account.name;
// how to get firstname and lastname here?
}
}
Run Code Online (Sandbox Code Playgroud)
如果你建议,我愿意采取其他方法 - 只要我能得到所有者的电子邮件,名字和姓氏.