在您的 Android Manifest 中,您应该有这样的部分来定义您的帐户验证器:
<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>
上面的元数据标记应该指向一个定义您的帐户的 XML 文件,如下所示:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="fm.last.android.account"
android:icon="@drawable/icon"
android:smallIcon="@drawable/icon"
android:label="@string/app_name"
android:accountPreferences="@xml/account_preferences"/>
上面的 android:accountPreferences 属性指向定义您的首选项屏幕的 XML 文件,如下所示:
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="General Settings" />
<PreferenceScreen
android:key="account_settings"
android:title="Account Settings"
android:summary="Sync frequency, notifications, etc.">
<intent
android:action="fm.last.android.activity.Preferences.ACCOUNT_SETUP"
android:targetPackage="fm.last.android"
android:targetClass="fm.last.android.activity.Preferences" />
</PreferenceScreen>
</PreferenceScreen>
上面的 PreferenceScreen 将启动一个显示设置屏幕的意图,但您也可以直接在 XML 文件中定义设置。