user123456
user123456

Reputation: 71

How to get default email account information in android..?

I am developing an application which requires to auto populate a default email field. The logical choice is to retrieve the email address from the email client provided by android. I searched the content providers and did not find anything about the email client. How is this information stored? How can I reach it?

Upvotes: 4

Views: 2137

Answers (1)

Vineet Shukla
Vineet Shukla

Reputation: 24021

Try this:

AccountManager accManager = AccountManager.get(context);
Account acc[] = accManager.getAccounts();
int accCount = acc.length;
AppConstants.accOnDevice = new Vector<String>();
for(int i = 0; i < accCount; i++){
//Do your task here...
}

Permission:

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

Upvotes: 2

Related Questions