From 08190bbb75ca9f5affb9d7b6474a87bc41256900 Mon Sep 17 00:00:00 2001 From: Fabrice Di Meglio Date: Fri, 16 May 2014 10:32:29 -0700 Subject: [PATCH] Fix bug #15016050 Stability: ISE in Settings: Cannot add twice the same OnSwitchChangeListener - add/remove the OnSwitchChangeListener into onResume/onPause Change-Id: Idb1ac3997a2dbc0ca387ed67bbbbcc1a431d8642 --- .../android/settings/DevelopmentSettings.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index d21e4ab0fe5..cc7a116f31d 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -387,19 +387,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment 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 @@ public class DevelopmentSettings extends SettingsPreferenceFragment 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) {