Created
October 12, 2013 06:51
-
-
Save Mak-Sym/6946670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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