这个问题讨论了Android设备的一般情况,但是如果您尝试在Kindle Fire上运行此代码,您只会得到用户的姓名。有没有办法获取电子邮件地址?我们希望弹出一个对话框,其中电子邮件地址已经预填,这样如果它正确,他们就不必输入它,但似乎唯一的解决方案是让他们重新输入。
编辑:这里是其他线程建议的代码(在Kindle Fire上无效):
Account[] accounts = AccountManager.get(this).getAccounts();
for (Account account : accounts) {
// TODO: Check possibleEmail against an email regex or treat
// account.name as an email address only for certain account.type values.
String possibleEmail = account.name;
// possibleEmail is a list of account names, hopefully including the @gmail.com address.
}