问题
Now I am doing a android project. The project needs to get the default username and password of Android phone.
I don't know how to get the default gmail information of one Android Cell Phone. Can u help me. Thanks.
回答1:
You should read about AccountManager to login using the gmail user but you will not get the username and password.
回答2:
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(context).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String possibleEmail = account.name;
...
}
}
Note that this requires the GET_ACCOUNTS permission:
来源:https://stackoverflow.com/questions/2817581/how-to-get-the-default-gmail-username-and-password