Pat*_*ick 14 android accounts android-syncadapter
我正在为Android应用程序实现一个syncadapter,并希望在"帐户和同步"菜单下对该帐户进行设置.我已经在DropBox应用程序中看到了这一点(如下所示),但我无法找到有关如何执行此操作的文档.我添加了帐户,只想在此菜单中添加指向帐户设置的链接.

小智 22
在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>
Run Code Online (Sandbox Code Playgroud)
上面的元数据标记应指向定义您的帐户的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"/>
Run Code Online (Sandbox Code Playgroud)
上面的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>
Run Code Online (Sandbox Code Playgroud)
上面的PreferenceScreen将启动显示设置屏幕的意图,但您也可以直接在XML文件中定义设置.
| 归档时间: |
|
| 查看次数: |
10784 次 |
| 最近记录: |