客户经理在Android中返回0个帐户

问题描述

我们建立了具有许多功能的SDK。在那里,我们正在尝试在Android帐户中保存一些令牌和标识符。

现在,我们正在观察的是,当我们尝试设置Account Manager类的setUserData()或getUserData()方法时,帐户管理器将返回0个帐户。

Logger.getInstance().writeFile("AccountManagerUtil::: save::: string value::: Account Manager details:: "+mAccountManager.getAccounts().length);
    mAccountManager.setUserData(mAccount,proxyKey(key),value == null ? "" : value);
    String retValue = mAccountManager.getUserData(mAccount,proxyKey(key));
    Logger.getInstance().writeFile("AccountManagerUtil::: save::: string value::: get user data::: "+retValue);

打印值如下:

    2020-10-09 09:29:14.015 AccountManagerUtil::: save::: byte value::: Account Manager details:: 0
2020-10-09 09:29:14.016 AccountManagerUtil::: proxyKey::: keys:: api.next.b.br:443//msso.magIdentifier
2020-10-09 09:29:14.018 AccountManagerUtil::: save::: byte value::: set user data is completed 
2020-10-09 09:29:14.018 AccountManagerUtil::: proxyKey::: keys:: api.next.b.br:443//msso.magIdentifier
2020-10-09 09:29:14.02 AccountManagerUtil::: save::: byte value::: get user data::: null

我创建帐户的方式如下:

mAccountManager = AccountManager.get(MAS.getContext());
            //Attempt to retrieve the account
            Account[] accounts = mAccountManager.getAccountsByType(accountType);
            Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: no of accounts "+accounts.length);
            for (Account account : accounts) {
                if (accountName.equals(account.name)) {
                    String password = mAccountManager.getpassword(account);
                    Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: account password "+password);
                    String savedPassword = identifier.toString();
                    if (password.equals(savedPassword)) {
                        mAccount = account;
                    }else {
                        // - case migration from old AccountManagerStoreDataSource
                        Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: SharedStorageIdentifier ");
                        mAccount = null;
                        identifier = new SharedStorageIdentifier();
                    }
                }
            }

            //Create the account if it wasn't retrieved,if (mAccount == null) {
                mAccount = new Account(accountName,accountType);
                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1)
                {
                    mAccountManager.removeAccountExplicitly(mAccount);
                }
                Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: adding account explicitly "+mAccount.name);
                boolean bAcc_status = mAccountManager.addAccountExplicitly(mAccount,identifier.toString(),null);
                Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: adding account status "+bAcc_status);
            }
            Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: getting account details:: Name:: "+mAccount.name+
                    " Type::" +mAccount.type+" hashcode::  "+mAccount.hashCode());
        } catch (Exception e) {
            Logger.getInstance().writeFile("AccountManagerUtil::: constructor::: shared storage exception "+e.getMessage());
            throw new MASSharedStorageException(e.getMessage(),e);
        }

我的问题是,我做错了什么。奇怪的行为是:

  1. 在最多的设备中,一切正常。代码没有变化。
  2. 大多数出现问题的设备是Motorola设备。三星或LG设备也在那里。
  3. 我们无法在内部复制该设备。甚至在模拟器中也没有。主要是对于某些最终用户而言。
  4. 如果我们对该设备进行了出厂重置,然后再次开始使用该设备,则一切正常。

是由于许可吗?还是设备帐户管理器或我的代码有问题?

请帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)