diff options
author | Lifu Tang <lifu@google.com> | 2013-09-03 14:29:13 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-03 14:29:13 -0700 |
commit | 42f82284a10163033842b1c93a8e767ca0527046 (patch) | |
tree | fa9754f96b102fc5c1a4b873df51070f2870842f /src/com/android/settings | |
parent | 8725d762038cd8af819ba45eee230e3af3623e0c (diff) | |
parent | b3cd38eab4402a95e779d4d0b92480b7c53fa473 (diff) | |
download | packages_apps_Settings-42f82284a10163033842b1c93a8e767ca0527046.tar.gz packages_apps_Settings-42f82284a10163033842b1c93a8e767ca0527046.tar.bz2 packages_apps_Settings-42f82284a10163033842b1c93a8e767ca0527046.zip |
am b3cd38ea: Merge "Fixed the crash on screen rotation" into klp-dev
* commit 'b3cd38eab4402a95e779d4d0b92480b7c53fa473':
Fixed the crash on screen rotation
Diffstat (limited to 'src/com/android/settings')
-rw-r--r-- | src/com/android/settings/location/LocationSettingsBase.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/com/android/settings/location/LocationSettingsBase.java b/src/com/android/settings/location/LocationSettingsBase.java index 81e841a27..9ceefe711 100644 --- a/src/com/android/settings/location/LocationSettingsBase.java +++ b/src/com/android/settings/location/LocationSettingsBase.java @@ -38,12 +38,29 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment private static final int LOADER_ID_LOCATION_MODE = 1; + /** + * Whether the fragment is actively running. + */ + private boolean mActive = false; + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); getLoaderManager().initLoader(LOADER_ID_LOCATION_MODE, null, this); } + @Override + public void onResume() { + super.onResume(); + mActive = true; + } + + @Override + public void onPause() { + super.onPause(); + mActive = false; + } + /** Called when location mode has changed. */ public abstract void onModeChanged(int mode, boolean restricted); @@ -61,7 +78,9 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment } mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF); - onModeChanged(mode, true); + if (mActive) { + onModeChanged(mode, true); + } return; } Settings.Secure.putInt(getContentResolver(), Settings.Secure.LOCATION_MODE, mode); @@ -69,9 +88,11 @@ public abstract class LocationSettingsBase extends SettingsPreferenceFragment } public void refreshLocationMode() { - int mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE, - Settings.Secure.LOCATION_MODE_OFF); - onModeChanged(mode, isRestricted()); + if (mActive) { + int mode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE, + Settings.Secure.LOCATION_MODE_OFF); + onModeChanged(mode, isRestricted()); + } } @Override |