我在执行一个syncadapter的Android应用程序,并想使设置在现有的账户账户与同步菜单。我已经看到了这在Dropbox的应用程序完成的(如下图所示),但我一直没能找到如何做到这一点的文档。我有占增加,只想补充在这个菜单中的链接帐户设置。
I am implementing a syncadapter for an android app and would like to make the settings for the account available under the "Accounts & sync" menu. I have seen this done in the DropBox app(as shown below), but I have not been able to find documentation on how to do this. I have the accounted added, just want to add a link to the account settings in this menu.
在你的Android清单,你应该有这样的一个部分来定义你的帐户身份验证:
In your Android Manifest, you should have a section like this to define your account authenticator:
<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文件:
The meta-data tag above should point to an XML file that defines your account, like this:
<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:帐户preferences属性以上几点定义您的preferences屏幕,像这样的XML文件:
The android:accountPreferences attribute above points to an XML file that defines your preferences screen, like so:
<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文件中定义的设置。
The above PreferenceScreen will launch an intent to display a settings screen, but you can also define the settings directly in the XML file.
上一篇:位图不绘制抗锯齿位图、抗锯齿
下一篇:如何显示登录屏幕只有一次?屏幕