1

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;
        }

2 Answers2

1

Replace the account type

com.yahoo.mobile.cllient.share.sync

to

com.yahoo.mobile.client.share.account

Neha
  • 1,548
  • 2
  • 10
  • 13
  • Madam : please check this link http://stackoverflow.com/questions/22590681/textview-button-not-showing-after-add-datepicker-in-android –  Mar 23 '14 at 13:02
  • Above link is not working, could you please share details for getting only Microsoft emails from AccountManager. Thanks in advance. – Ravikumar11 Oct 06 '16 at 14:45
1

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;
        }
    }
Kennedy Kambo
  • 372
  • 4
  • 24
  • does the exchange type include microsoft office 365 accounts as well? – ZooS Mar 26 '18 at 16:47
  • haven't tried that one yet but let me try and i'll get back to you.Meanwhile also do the same.And if it helped you can mark it as an answer – Kennedy Kambo Mar 26 '18 at 18:48
  • I have discovered that for Microsoft Office 365 accounts and similar there are additional packages to be considered. These are `"com.microsoft.android.enterprise15", "com.microsoft.skydrive", "com.microsoft.workaccount"` – ZooS Mar 29 '18 at 09:11
  • glad you found the solution.I don't have a microsoft 365 account. – Kennedy Kambo Mar 29 '18 at 10:54
  • also with the account.name and all emails you might need already registered in your phone,you can get all their types.Its how I ended up with the three – Kennedy Kambo Mar 29 '18 at 10:58