-1

I want to get the email id from android device. i saw AccountManager will help. but it is from api level 8. my application needs to support for all API levels. so can please share any document to get the email id.

1 Answers1

0

// API level 5+

Pattern email = Patterns.EMAIL_ADDRESS; 
    Account[] accounts = AccountManager.get(context).getAccounts();
    for (Account account : accounts) {
        if (emailPattern.matcher(account.name).matches()) {
            String possibleEmail = account.name;
        }
    }

API level 14+

Use ContactsContract.Profile

Detailed answer by Roman Nurik

https://stackoverflow.com/a/2175688/3020568

Community
  • 1
  • 1
Deniz
  • 12,332
  • 10
  • 44
  • 62