Show settings under accounts & sync menu for android app
Asked Answered
V

2

14

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.

enter image description here

Veldaveleda answered 18/5, 2012 at 19:0 Comment(0)
T
23

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>

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"/>

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>

The above PreferenceScreen will launch an intent to display a settings screen, but you can also define the settings directly in the XML file.

Thirdrate answered 20/5, 2012 at 18:58 Comment(1)
This old qsn! but Intent intent=new Intent(Settings.ACTION_SYNC_SETTINGS); //ACTION_SETTINGS startActivity(intent); not launching the preference screen !!Victoir
C
0

If i understood correctly, You want to show up "Accounts & sync settings" screen from within your application. For this you have to fire an intent for settings. Use code given below:

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);

Hope this helped...

Cloninger answered 18/5, 2012 at 20:16 Comment(1)
No this not what I am trying to do(although its good to know this). I am trying to add the " general settings" under the.accounts menu as is shown in pic aboveVeldaveleda

© 2022 - 2024 — McMap. All rights reserved.