显示“帐户”下的设置&;android应用程序的同步菜单
我正在为android应用程序实现syncadapter,并希望在“Accounts&sync”菜单下提供该帐户的设置。我在DropBox应用程序中看到了这一点(如下所示),但我还没有找到关于如何做到这一点的文档。我已添加帐户,只想在此菜单中添加帐户设置的链接显示“帐户”下的设置&;android应用程序的同步菜单,android,android-syncadapter,accounts,Android,Android Syncadapter,Accounts,我正在为android应用程序实现syncadapter,并希望在“Accounts&sync”菜单下提供该帐户的设置。我在DropBox应用程序中看到了这一点(如下所示),但我还没有找到关于如何做到这一点的文档。我已添加帐户,只想在此菜单中添加帐户设置的链接 如果我理解正确,您希望在应用程序中显示“帐户和同步设置”屏幕。为此,您必须激发设置意图。使用下面给出的代码: Intent intent = new Intent(Intent.ACTION_MAIN); intent.setCompon
如果我理解正确,您希望在应用程序中显示“帐户和同步设置”屏幕。为此,您必须激发设置意图。使用下面给出的代码:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.providers.subscribedfeeds","com.android.settings.ManageAccountsSettings"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
希望这对您有所帮助…在您的Android清单中,您应该有这样一个部分来定义您的帐户验证器:
<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>
上面的首选项屏幕将启动显示设置屏幕的意图,但您也可以直接在XML文件中定义设置。否这不是我要做的(尽管知道这一点很好)。我正在尝试在.accounts菜单下添加“常规设置”,如上图所示,这是一个旧的qsn!但是意图=新意图(Settings.ACTION\u SYNC\u Settings)//动作设置开始触觉(意图);不启动首选项屏幕!!