Friends I am making a security app in which when the user will click forgot password and I want to send his password to his G-mail account associated with the Google play account.So Question is, how can I come to know his G-mail ID?
Asked
Active
Viewed 1,209 times
1 Answers
5
You can use AccountManager.getAccounts or AccountManager.getAccountsByType to get a list of all account names on the device.
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;
...
}
}
requires the GET_ACCOUNTS permission:
uses-permission android:name="android.permission.GET_ACCOUNTS" />
you can also use the code at https://developers.google.com/gmail/android/
-
Of course there is no way of knowing if this is associated with the Play Store or not. Additionally, the Play Store supports multiple accounts, so potentially every account can be associated. Getting the first "com.google" account is usually the best bet. – Nikolay Elenkov Nov 20 '12 at 08:44
-
Ok guys...there is an app in market "Findroid" In this app as you set your password, you will get an email on account registered on the Play Store. – Caution Continues Nov 21 '12 at 06:52