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?
Android: read preferences set in authenticator xml
715 views Asked by AndyAndroid At
1
From the documentation for AbstractAccountAuthenticator:
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.
EDIT
For a very basic working example, you can download the sample app from the Sync Adapter Training Docs and edit as follows.
Create
res/xml/account_preferences.xml
that looks like thisAdd
android:accountPreferences="@xml/account_preferences"
to theaccount-authenticator
tag inauthenticator.xml
.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.