Je suis paramètres préférence dans une case à cocher via un compte-authentificateur:Impossible d'accéder à des préférences définies compte-authentificateur dans Android
Intent settingsIntent = new Intent("android.settings.ACCOUNT_SYNC_SETTINGS");
settingsIntent.putExtra("account", mActiveAccount);
startActivityForResult(settingsIntent, ACCOUNT_COMPLETE);
avec le xml:
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="com.example.auth"
android:label="@string/auth_label"
android:accountPreferences="@xml/auth_preferences" />
et en auth_preferences.xml je:
<?xml version="1.0" encoding="UTF-8" ?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/auth_preferences_general_group" />
<PreferenceScreen android:key="account_settings"
android:title="@string/auth_preferences_general_details_title"
android:summary="@string/auth_preferences_general_details_description">
<intent android:action="com.example.ACCOUNT_SETUP"
android:targetPackage="com.example.core"
android:targetClass="com.example.authentication.AuthenticatorAccountOptions" />
</PreferenceScreen>
<PreferenceCategory android:title="@string/auth_preferences_data_sync_group" >
<CheckBoxPreference
android:key="checkbox_pref"
android:title="@string/auth_preferences_data_sync_syncwidget_title"
android:summary="@string/auth_preferences_data_sync_syncwidget_description"
android:defaultValue="true"
android:persistent="true" />
</PreferenceCategory>
Mais je ne peux pas accéder à ces préférences case à cocher dans le code principal quand je tente de le récupérer:
SharedPreferences prefs = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
boolean isChecked = prefs.getBoolean("checkbox_pref", true);
Quelqu'un sait où les préférences fondées compte authentificateur sont accessibles à partir?
Comment feriez-vous cela? Et pourquoi est-il possible de créer des préférences si vous ne pouvez pas les lire? – AndyAndroid
Ceci n'est pas seulement la solution commune mais aussi ce qui est prévu pour [AbstractAccountAuthenticator] (http://developer.android.com/reference/android/accounts/AbstractAccountAuthenticator.html): "L'attribut preferences pointe vers une hiérarchie xml PreferenceScreen contient une liste de PreferenceScreens pouvant être appelée pour gérer l'authentificateur. " – mpkuth