问题描述
我正在尝试使用Android AccountManager
.
I'm experimenting with Android AccountManager
.
我有一个帐户身份验证服务,其中显示了用于输入用户名/密码的UI.
I have an Account authentication service that shows UI to enter username/password.
我转到设置/帐户/添加帐户",选择我的新帐户类型,然后显示用户界面.
I go to Settings/Accounts/Add Account, choose my new account type and I'm presented with the UI.
当我单击确定"时,出现以下错误
When I click OK I get the following error
04-24 14:48:29.334: E/AndroidRuntime(386): java.lang.SecurityException:
caller uid 10035 is different than the authenticator's uid
MyAccountAuthenticationService的唯一方法:
The only method of MyAccountAuthenticationService:
@Override
public IBinder onBind(Intent intent) {
return new MyAccountAuthenticator(this).getIBinder();
}
MyAccountAuthenticator:
MyAccountAuthenticator:
@Override
public Bundle addAccount(AccountAuthenticatorResponse response,
String accountType, String authTokenType, String[] requiredFeatures,
Bundle options) throws NetworkErrorException {
final Intent intent = new Intent(context, MyAccountCreatorActivity.class);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
final Bundle bundle = new Bundle();
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
return bundle;
}
MyAccountCreatorActivity 的 onClick
Fragment of MyAccountCreatorActivity
's onClick
AccountManager accManager = AccountManager.get(this);
Account newAccount = new Account(email, MyAccountAuthenticator.ACCOUNT_TYPE);
accManager.setPassword(newAccount, password);
在 setPassword
上引发异常.我已经需要所有会计权限.我不确定是什么原因造成的.如果您需要更多代码/信息,请询问.
Exception is thrown on setPassword
. I already required all the accounting permissions. I'm not sure about what could be causing this. If you need more code/information please ask.
谢谢.
推荐答案
由于@imran khan,我发现我的常量值与身份验证器XML定义"中的完全不匹配"
Thanks to @imran khan, I discovered that my constant value didn't match "exactly" what was in the authenticator XML definition
这篇关于尝试添加帐户时出现SecurityException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!