Question

Is it possible to get Yahoo/Microsoft email id/ ids which are configured with PlayStore app in android device. I use com.yahoo.mobile.client.share.sync for Yahoo. But Not Working .May I know what is the correct way to achieve my objective?

Here is my code:

public String[] allemails()
        {

             _accountMgr = AccountManager.get(getActivity());
               // Account [] accounts = _accountMgr.getAccounts();

              //  Account [] accounts = _accountMgr.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
             Account [] accounts = _accountMgr.getAccountsByType("com.yahoo.mobile.client.share.sync");

             numberOfEmail = accounts.length ;
                String [] emailAddress = new String[numberOfEmail];

                r = 0;
                for (Account account : accounts) {
                    accountsList = account.name.toString();
                    emailAddress[r] = accountsList;
                    r += 1;

                }

                MyAlertDialog f = new MyAlertDialog();
                Bundle args = new Bundle();
                args.putStringArray("Title", emailAddress);
                f.setArguments(args);

                return  emailAddress;
        }
Was it helpful?

Solution

Replace the account type

com.yahoo.mobile.cllient.share.sync

to

com.yahoo.mobile.client.share.account

OTHER TIPS

This is late but it might help someone.To get google,yahoo,microsoft accounts...use either of the three:

String email = null;

    Pattern gmailPattern = Patterns.DOMAIN_NAME;
    AccountManager manager = AccountManager.get(this);
    Account[] accounts = manager.getAccountsByType("com.google");
    for (Account account : accounts) {
        if (gmailPattern.matcher(account.name).matches()) {
            email = account.name;
        }
    }
    Account[] accounts1 = manager.getAccountsByType("com.android.email");
    for (Account account : accounts1) {
        if (gmailPattern.matcher(account.name).matches()) {
            email = account.name;
        }
    }
    Account[] accounts2 = manager.getAccountsByType("com.android.exchange");
    for (Account account : accounts2) {
        if (gmailPattern.matcher(account.name).matches()) {
            email = account.name;
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top