Come menzionato nei commenti, la risposta di Roman a How to get the Android device's primary e-mail address lo risolve. Ecco il codice che ho usato che rimuoverà anche il nome utente dall'email.
public String getUsername() {
AccountManager manager = AccountManager.get(this);
Account[] accounts = manager.getAccountsByType("com.google");
List<String> possibleEmails = new LinkedList<String>();
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.
possibleEmails.add(account.name);
}
if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) {
String email = possibleEmails.get(0);
String[] parts = email.split("@");
if (parts.length > 1)
return parts[0];
}
return null;
}
fonte
2010-04-30 00:51:36
Vedere la mia risposta qui: http://stackoverflow.com/questions/2112965 –