Get Configured Email Address From Android Device Programmatically

In java code need the following piece of code.

String gmail = null;

    Pattern gmailPattern = Patterns.EMAIL_ADDRESS; // API level 8+

    Account[] accounts = AccountManager.get(this).getAccounts();

    for (Account account : accounts) {

        if (gmailPattern.matcher(account.name).matches()) {

            gmail = account.name;

        }

    }

    Log.d(“gmail”, gmail+“**”);

And also need permission in AndroidManifest.xml

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

Get Configured Email Address From Android Device Programmatically

In java code need the following piece of code.

String gmail = null;

    Pattern gmailPattern = Patterns.EMAIL_ADDRESS; // API level 8+

    Account[] accounts = AccountManager.get(this).getAccounts();

    for (Account account : accounts) {

        if (gmailPattern.matcher(account.name).matches()) {

            gmail = account.name;

        }

    }

    Log.d(“gmail”, gmail+“**”);

And also need permission in AndroidManifest.xml

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