How do you get the Android\'s primary e-mail address (or a list of e-mail addresses)?
It\'s my understanding that on OS 2.0+ there\'s support for multiple e-mail add
Use this method:
public String getUserEmail() {
AccountManager manager = AccountManager.get(App.getInstance());
Account[] accounts = manager.getAccountsByType("com.google");
List possibleEmails = new LinkedList<>();
for (Account account : accounts) {
possibleEmails.add(account.name);
}
if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) {
return possibleEmails.get(0);
}
return "";
}
Note that this requires the GET_ACCOUNTS
permission:
Then:
editTextEmailAddress.setText(getUserEmail());