I am using a preferenceActivity in android to manipulate my shared preferences. I figured out how to change the summary with an OnSharedPreferenceChangeListener from within the preferenceActivity. However, I am using a picker wheel so I use an intent to launch it from the preference activity like this...
<Preference
android:summary="Snooze Picker Wheel"
android:title="Snooze Timer"
android:key="snooze_pref">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="com.example.alarm.SnoozePicker"
android:targetPackage="com.example.alarm" />
</Preference>
I've been researching, but I cannot find a way to update the summary of the picker wheel to the item that is selected. So my question is, is there a way to change the summary of a preferenceActivity from a different activity? What would be the implementation for that, and where could I learn more about specifically changing the summary from a different activity? Thank you for any help.
Edit: I got something working by setting a shared preference in the snoozePicker activity and then setting it like this in the preference activity in onCreate and onResume
if (sharedpreferences.contains(Snooze)) {
int prefs = sharedpreferences.getInt(Snooze, -1);
Preference editSnoozePref = (Preference) findPreference("snooze_pref");
editSnoozePref
.setSummary("Snooze Setting is " + prefs + " minutes");
}
AFAIK, it is not possible to change summary from other Activity
.
As a work around, you can save the summary in a SharedPreference
and set this summary when your PreferenceActivity
is created. It will be seamless experience for the user as the summary will be visible only after PreferenceActivity
is created.