How Can I Get email ids of Yahoo/Microsoft Account

≯℡__Kan透↙ 提交于 2019-12-11 06:39:48

问题


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

回答1:


Replace the account type

com.yahoo.mobile.cllient.share.sync

to

com.yahoo.mobile.client.share.account




回答2:


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


来源:https://stackoverflow.com/questions/22481360/how-can-i-get-email-ids-of-yahoo-microsoft-account

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!