android中accountManager的getPassword中出现SecurityException

par*_*rul 5 android google-account getpasswd accountmanager

我正在尝试检索 google 帐户的密码,但在 String pwd = AccountManager.get(mContext).getPassword(account) 处出现安全异常。另外,我已在 androidManifest.xml 中向 account_manager、authenticator、get_account、管理帐户授予权限。

代码 :

android.accounts.Account[] gaccounts = AccountManager.get(mContext).getAccounts();
Log.i("parul", "2222()len :"+ gaccounts.length);
for (android.accounts.Account account: gaccounts) {
   String pwd = AccountManager.get(mContext).getPassword(account);
   Log.i("parul", "google pwd: " + pwd);
   AccountManager.get(mContext).setPassword(account, null);
   String pwdcleared = AccountManager.get(mContext).getPassword(account);
   Log.i("parul", "google pwdcleared: " + pwdcleared);
}
Run Code Online (Sandbox Code Playgroud)

=================================================== ===========================

例外:

08-04 06:38:30.821: WARN/AccountManagerService(2248): 调用者 uid 1000 与身份验证器的 uid 不同

08-04 06:38:30.821: INFO/parul(2804): 为客户经理 try 块抛出异常

08-04 06:38:30.821:WARN / System.err(2804):java.lang.SecurityException:调用者uid 1000与身份验证器的uid不同

08-04 06:38:30.821:警告/System.err(2804):在android.os.Parcel.readException(Parcel.java:1218)

08-04 06:38:30.821:警告/System.err(2804):在android.os.Parcel.readException(Parcel.java:1206)

08-04 06:38:30.821: WARN/System.err(2804): 在 android.accounts.IAccountManager$Stub $Proxy.getPassword(IAccountManager.java:397)

08-04 06:38:30.821:警告/System.err(2804):在android.accounts.AccountManager.getPassword(AccountManager.java:157)

=================================================== ===========================

如果有人知道我为什么会遇到这个问题,请帮助。谢谢

ank*_*nfo 1

据我阅读这篇文章,错误是由于配置不匹配造成的。需要你仔细推敲