Fix bug #15016050 Stability: ISE in Settings: Cannot add twice the same OnSwitchChangeListener
- add/remove the OnSwitchChangeListener into onResume/onPause
Change-Id: Idb1ac3997a2dbc0ca387ed67bbbbcc1a431d8642
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index d21e4ab..cc7a116 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -387,19 +387,6 @@
mEnabledSwitch.setEnabled(false);
return;
}
- mSwitchBar.addOnSwitchChangeListener(this);
- }
-
- @Override
- public void onStart() {
- super.onStart();
- mSwitchBar.show();
- }
-
- @Override
- public void onStop() {
- super.onStop();
- mSwitchBar.hide();
}
private boolean removePreferenceForProduction(Preference preference) {
@@ -464,6 +451,17 @@
mEnabledSwitch.setChecked(mLastEnabledState);
setPrefsEnabledState(mLastEnabledState);
}
+
+ mSwitchBar.addOnSwitchChangeListener(this);
+ mSwitchBar.show();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+
+ mSwitchBar.removeOnSwitchChangeListener(this);
+ mSwitchBar.hide();
}
void updateCheckBox(CheckBoxPreference checkBox, boolean value) {