Skip to content

Instantly share code, notes, and snippets.

@Mak-Sym Mak-Sym/gist:6946651
Created Oct 12, 2013

Embed
What would you like to do?
@Override
protected void onPause() {
super.onPause();
// Unregister the listener whenever a key changes
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
protected void onResume() {
super.onResume();
//update phone preference summary with actual value
SharedPreferences preferences = getPreferenceScreen().getSharedPreferences();
phoneNumberPreference.setSummary(preferences.getString(PHONE_NUMBER_PREFERENCE, getResources().getString(R.string.phone_number_desc)));
preferences.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
//update phone preference summary with actual value
if(key.equals(PHONE_NUMBER_PREFERENCE)){
phoneNumberPreference.setSummary(preferences.getString(key, getResources().getString(R.string.phone_number_desc)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.