Android 帐户身份验证服务未注册
我有以下帐户身份验证类Android 帐户身份验证服务未注册,android,Android,我有以下帐户身份验证类 public class AppAuthenticator extends AbstractAccountAuthenticator { private Context mContext; public AppAuthenticator(Context context) { super(context); mContext = context; } //This is used by the login activity when the guy l
public class AppAuthenticator extends AbstractAccountAuthenticator {
private Context mContext;
public AppAuthenticator(Context context) {
super(context);
mContext = context;
}
//This is used by the login activity when the guy logs in after starting the app
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
String[] requiredFeatures, Bundle options)
throws NetworkErrorException {
//...Code Here...
}
}
与
及舱单:
xml/authenticator.xml
<account-authenticator
xmlns:android="http://schems.android.com/apk/res/android"
android:accountType="@string/account_type"
android:label="@string/app_name"
android:icon="@drawable/benchcap" />
我尝试添加帐户,但得到SecurityException“调用方UID不同于验证器UID”(此处描述:)。这是有道理的,因为服务没有注册
系统只提供了这些信息
要正确注册身份验证服务,需要添加哪些内容?您是否尝试过在XML文件中为帐户类型使用常规字符串(而不是资源)?您的代码似乎正确,唯一的问题是您正在一个单独的进程中运行该服务。有什么特别的原因吗?(android:process=“:auth”位)不,我从教程中选择了这一行,我认为这是必需的。让我尝试不使用它……并且……我在运行时仍然会收到“called uid error”。我不知道是否必须这样做,但我从一个
ASyncTask
(不同的线程)调用AppAuthenticator::addAccount()。也许它也必须这样做,但AccountTypeManager在部署时说:“找不到type=com.android.exchange的验证器,将忽略它。”我不知道该类型是由谁定义的。
<account-authenticator
xmlns:android="http://schems.android.com/apk/res/android"
android:accountType="@string/account_type"
android:label="@string/app_name"
android:icon="@drawable/benchcap" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.app"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<application
android:name="com.app.app.AppApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service android:name=".AuthenticationService"
android:exported="true" android:process=":auth">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
</application>
"Unable to load service info ResolveInfo{40f00c40 com.app.app.AuthenticationService p=0 m=0x108000}
Loaded meta-data for 0 account types, 0 accounts in 4ms(wall) 2ms(cpu)"