I am using the following code for adding a listener in prefernceactivity. But its not working. Please give a idea for this.
public class Preference extends PreferenceActivity implements OnSharedPreferenceChangeListener {
OnSharedPreferenceChangeListener listener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
// TODO Auto-generated method stub
}
}
You have to register your listener first.
The best way is to register it in
onResume
and unregister inonPause
: