The question about design is basically - having PreferenceActivity, should it be implemented OnSharedPreferenceChangeListeneror is it necessary to define this functionality in another class - say, in the inner class? Is there any reason someone prefers a different approach?
And where should the listener be registered? I mean documents and common sense dictate to register / unregister onResume/onPauseaccordingly, but seeing a zillion registration in onCreateI am just wondering if I missed something.
In addition, I’m not quite sure that the refusal to register (so here , for example, non- registration cannot be caused because onStopit cannot be called) will certainly lead to a leak. Therefore, if I have, for example,
class MyPref extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
SharedPreferences sharedPreferences;
onStart(){
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
}
Will this leak be an instance MyPrefwhen I get back to one of my other actions?
Finally - are the same considerations applicable to OnPreferenceChangeListener?
Edit: back to the fact that I don’t see a way to unregister OnPreferenceChangeListener- am I blind?
source
share