I want to get and display the users mail accounts list when my apps gets installed .For eg:I am having 3 accounts in my mobile ,when my app get installed it should display three accounts .How can i get the user registered accounts? Any tutorial or link will be advisable.
Asked
Active
Viewed 192 times
0
-
Excellent Explanation can be found [here][1] [1]: http://stackoverflow.com/a/2175688/1696704 – Software Sainath Sep 27 '13 at 09:25
-
You can get it from here : http://www.demoadda.com/demo/android/getregistered-email-account-from-device_96 – Kishan Dhamat Dec 29 '15 at 14:24
1 Answers
1
You can also use the AccountManager to retrieve the Gmail address entered.
Here is the way I use :
private String getFirstAccount() {
Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(Compte.this).getAccounts();
for (Account account : accounts) {
if (emailPattern.matcher(account.name).matches()) {
String possibleEmail = account.name;
return possibleEmail;
}
}
return null;
}
marshallino16
- 2,645
- 15
- 29