AccountManager :: addAccountExplicitly()无法创建帐户

时间:2018-01-08 14:15:20

标签: android accountmanager

我的应用程序无法使用AccountManager :: addAccountExplicitly()创建Android帐户。我不明白为什么它失败了,我也看不到AccountManager在logcat中报告的任何错误。

我正在尝试创建帐户,如果失败则重试一次。如果失败发生两次,我就会提出异常。

但是,在失败期间,没有办法弄清楚为什么addAccountExplicitly()失败了?

我的应用程序即使在重试之后也无法添加帐户,之后我提出异常。

这是我正在做的事情,

Account account = new Account(accountName, accountType);
String password = getPassword();

boolean accountCreated = mAccountManager.addAccountExplicitly(account, password, null);

if (!accountCreated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1)
{
      // addAccountExplicitly can return false if the account already exists
      // but at this point, I would always want to create a new account. 
      // Hence, will attempt to remove and add account.

      mAccountManager.removeAccountExplicitly(account);
      accountCreated = mAccountManager.addAccountExplicitly(account, password, null);

       if (!accountCreated)
        {
              throw new IllegalStateException());
        }
   }

任何人都可以指导我缺少的东西吗? 我想知道addAccountExplicitly()失败的场景是什么。如何在出现故障时检查错误信息?

1 个答案:

答案 0 :(得分:0)

我还向Google提出了这个问题: - https://issuetracker.google.com/issues/71697888

相关问题