最佳答案
I have a class that extends PreferenceActivity and shows the preference screen of my app. Is it possible to check if any changes were made to the preferences?
This helps...
Other related post: SharedPreferences.onSharedPreferenceChangeListener not being called consistently
public class PreferenceClass extends PreferenceActivity {
OnSharedPreferenceChangeListener listener;
public void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = this.getSharedPreferences("settings", 0);
listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
int flag = 1;
}
};
prefs.registerOnSharedPreferenceChangeListener(listener);
super.onCreate(null);
addPreferencesFromResource(R.xml.settings);
}
}