addAccountExplicitly抛出IllegalStateException异常造成SecurityException异常 [英] addAccountExplicitly throws IllegalStateException caused by Securityexception

查看:2524
本文介绍了addAccountExplicitly抛出IllegalStateException异常造成SecurityException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此code抛出该异常并且不添加创建的帐户到客户经理

using this code throws that exception and doesnt add created account into account manager

AccountManager am = AccountManager.get(activity);
Account acc = new Account(name,activity.getString(R.string.account_type));
am.addAccountExplicitly(acc,"Password",null);

我跟着这个 - http://developer.android.com/training/ ID-AUTH / custom_auth.html

什么想法?

//编辑:致:java.lang.SecurityException异常:来电UID 10035比认证的uid不同

//edit: Caused by: java.lang.SecurityException: caller uid 10035 is different than the authenticator's uid

推荐答案

的文档<一个href="http://developer.android.com/reference/android/accounts/AccountManager.html#addAccountExplicitly%28android.accounts.Account,%20java.lang.String,%20android.os.Bundle%29"相对=nofollow> AddAccountExplicitly 说:

此方法需要调用者持有许可   AUTHENTICATE_ACCOUNTS并有相同的UID作为加入帐户的   认证者。

This method requires the caller to hold the permission AUTHENTICATE_ACCOUNTS and to have the same UID as the added account's authenticator.

这引发的SecurityException异常解释该问题,正尝试添加帐户的应用中的UID是从认证的UID不同。换句话说它们是两个不同的应用程序。

The SecurityException that is thrown explains the problem, the UID of the application that is trying to add the account is different from the UID of the authenticator. In other words they are two different applications.

如果你想这两个是独立的应用程序,你可以确保你分享他们之间的UID。请参阅机器人:此页面的sharedUserId一节多一点如何做到这一点的信息。

If you want these two to be separate applications you could make sure you share the UID between them. See the android:sharedUserId section of this page for a bit more information on how to do that.

这篇关于addAccountExplicitly抛出IllegalStateException异常造成SecurityException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆