A Bunch of questions regarding Android PreferenceActivity?

If the BroadcastReceiver is registered in the manifest, you don't listen to changes in your preferences, because the BroadcastReceiver will only be around for milliseconds. Just read the latest values in during onReceive() If the BroadcastReceiver is registered by some other component calling registerReceiver() that component can register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences() Its look like that the context of the broadcast reciever is not the same as the activity so i'm not registering to the right SharedPreferences because I don't intercept those changes That sentence makes no sense How do I act in my PreferenceActivity upon changes in the preferences? Register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences() How do I change the UI of the PreferenceActivity appropriate to the changes in the preferences?

Generally, you don't. You are welcome to register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences() From there, you can get the Preference from your PreferenceActivity via findPreference() and adjust to suit How do I enable or disable some preferences that depends on another preference (like CheckBoxPreference)? So the user could edit those preferences only if he enabled the feature first Add android:dependency to your preference XML as needed.

If the BroadcastReceiver is registered in the manifest, you don't listen to changes in your preferences, because the BroadcastReceiver will only be around for milliseconds. Just read the latest values in during onReceive(). If the BroadcastReceiver is registered by some other component calling registerReceiver(), that component can register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences().

Its look like that the context of the broadcast reciever is not the same as the activity so i'm not registering to the right SharedPreferences because I don't intercept those changes. That sentence makes no sense. How do I act in my PreferenceActivity upon changes in the preferences?

Register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences(). How do I change the UI of the PreferenceActivity appropriate to the changes in the preferences? Generally, you don't.

You are welcome to register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences(). From there, you can get the Preference from your PreferenceActivity via findPreference() and adjust to suit. How do I enable or disable some preferences that depends on another preference (like CheckBoxPreference)?

So the user could edit those preferences only if he enabled the feature first. Add android:dependency to your preference XML as needed.

I saw that android:dependency but I didn't new what value should I provide. Can you elaborate on that a little? – Avrahamshuk May 8 at 22:03 @Avrahamshuk: As the documentation says, it is "the key of another Preference that this Preference will depend on".

If you have a preference named "foo" and one named "bar", and "bar" should only be enabled if "foo" is checked, then add android:dependency="foo" to the "bar" preference in the XML. – CommonsWare May 8 at 22:06 1 Use the "key" value of CheckBox. – Corkscreewe May 8 at 22:07.

Register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences(). How do I change the UI of the PreferenceActivity appropriate to the changes in the preferences? Generally, you don't.

You are welcome to register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences(). From there, you can get the Preference from your PreferenceActivity via findPreference() and adjust to suit. How do I enable or disable some preferences that depends on another preference (like CheckBoxPreference)?

So the user could edit those preferences only if he enabled the feature first. Add android:dependency to your preference XML as needed.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions