You can retrieve the email accounts configured on the device's native email client.
public Vector fetchConfiguredEmail(Context context){
AccountManager accManager = AccountManager.get(context);
Account acc[] = accManager.getAccounts();
int accCount = acc.length;
Vector accounts = new Vector();
for(int i = 0; i < accCount; i++){
if(acc[i].name.trim().indexOf("@")!=-1){
accounts.add(acc[i].name);
}
}
return accounts;
}
Permission: You need to add this permission to your manifest file:
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
No comments:
Post a Comment