如何获取Yahoo / Microsoft帐户的电子邮件ID

时间:2014-03-18 13:48:24

标签: android android-account

是否有可能获得在Android设备中配置了PlayStore应用程序的Yahoo / Microsoft电子邮件ID / ID。我为雅虎使用 com.yahoo.mobile.client.share.sync 。但不工作。可能我知道实现目标的正确方法是什么?

这是我的代码:

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 个答案:

答案 0 :(得分:1)

替换帐户类型

  

com.yahoo.mobile.cllient.share.sync

  

com.yahoo.mobile.client.share.account

答案 1 :(得分:1)

这已经很晚了,但它可能对某人有所帮助。要获得谷歌,雅虎,微软帐户......使用以下三者之一:

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