我正在尝试在this帖子之后在Xamarin Droid中实现自定义帐户身份验证器。我无法运行服务(当应用程序启动时,断点都没有被触发,即使我注释掉整个服务也没有出现任何错误。我在这里遗漏了什么吗?
我的androidmanifest.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="21" />
<application>
<service android:name="AccountAuthenticatorService" 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>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
我的服务是
[Service]
public class AccountAuthenticatorService : Service
{
private static String TAG = "AccountAuthenticatorService";
private static AccountAuthenticatorImpl sAccountAuthenticator = null;
public AccountAuthenticatorService () : base()
{
}
public override IBinder OnBind(Intent intent) {
IBinder ret = null;
if (intent.Action.Equals (Android.Accounts.AccountManager.ActionAuthenticatorIntent))
ret = getAuthenticator().IBinder;
return ret;
}
private AccountAuthenticatorImpl getAuthenticator() {
if (sAccountAuthenticator == null)
sAccountAuthenticator = new AccountAuthenticatorImpl(this);
return sAccountAuthenticator;
}
}
我有以
开头的AccountAuthenticator实现public class AccountAuthenticatorImpl : AbstractAccountAuthenticator
{
private Context mContext;
public AccountAuthenticatorImpl(Context context) : base(context) {
mContext = context;
}