Unable to access preferences set in account authenticator in Android

I set preferences in the check box through account authenticator:

Intent settingsIntent = new Intent("android.settings.ACCOUNT_SYNC_SETTINGS");
settingsIntent.putExtra("account", mActiveAccount);
startActivityForResult(settingsIntent, ACCOUNT_COMPLETE);

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

In auth_ Preferences.xml I have:

<?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" >
    <Check@R_894_2419@Preference
          android:key="check@R_894_2419@_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>   

However, when I try to retrieve it, I cannot access this checkbox preference in the main code:

SharedPreferences prefs = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
boolean isChecked = prefs.getBoolean("check@R_894_2419@_pref", true);

Does anyone know where to access account based authenticator preferences?

resolvent:

Based on auth_ Changes made in the activity of preferences.xml will be saved to com.android.settings_ Preferences.xml and cannot be accessed using the application's getsharedpreferences (file, context). The common solution I found is to trigger a new preferenceactivity in the account preferences

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>