I want to read in my code preferences I have set via the authenticator xml file. I found Can't access preferences set in account-authenticator in Android and How can access preferences set in account-authenticator in Android one is completely unanswered and the other says I need to create my own activity. This really sounds odd since that would mean that the preferences I can configure via xml are useless because I never can read them again. That cannot be. Does someone know more about it? If I really have to create an own activity, how would I do this in the case of the authenticator?
Best How To :
From the documentation for AbstractAccountAuthenticator:
The preferences attribute points to a PreferenceScreen xml hierarchy that contains a list of PreferenceScreens that can be invoked to manage the authenticator. An example is:
So it appears that even though it is possible to put individual preferences in
account_preferences.xml it is not intended to be done so the values are not accessible.
See this question and answer for details about how to setup and handle the PreferenceScreen intent.
For a very basic working example, you can download the sample app from the Sync Adapter Training Docs and edit as follows.
res/xml/account_preferences.xml that looks like this
<?xml version="1.0" encoding="UTF-8" ?>
android:accountPreferences="@xml/account_preferences" to the
account-authenticator tag in
This example starts up an existing activity in the example, but could easily start a PreferenceActivity (or any other activity you want). See the Settings guide for details about how to set up the PreferenceActivity.
For a real world example from a core Android app, see the implementation of the Email app here.