我正在尝试检索 google 帐户的密码,但在 String pwd = AccountManager.get(mContext).getPassword(account) 处出现安全异常。我还在 androidManifest.xml 中授予 account_manager、aunthenticator、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);
}
==================================================== ============================
例外:
08-04 06:38:30.821: WARN/AccountManagerService(2248): caller uid 1000 与验证者的 uid 不同
08-04 06:38:30.821: INFO/parul(2804): 为客户经理尝试块抛出异常
08-04 06:38:30.821: WARN/System.err(2804): java.lang.SecurityException: caller uid 1000 is different than the authenticationator's uid
08-04 06:38:30.821: WARN/System.err(2804): 在 android.os.Parcel.readException(Parcel.java:1218)
08-04 06:38:30.821: WARN/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: WARN/System.err(2804): 在 android.accounts.AccountManager.getPassword(AccountManager.java:157)
==================================================== ============================
如果有人知道为什么我会遇到这个问题,请帮忙。谢谢