Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
save loggingEnabled state on Activity recreation
Browse files Browse the repository at this point in the history
closes #6
  • Loading branch information
tjanson committed Mar 14, 2015
1 parent 22258a5 commit 188ddd0
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class MainActivity extends Activity implements
private final static String LOCATION_KEY = "location-key";
private final static String LAST_LOCATION_UPDATE_TIME_STRING_KEY = "last-location-update-time-string-key";
private final static String LAST_WIFI_SCAN_TIME_STRING_KEY = "last-wifi-scan-time-string-key";
private final static String LOGGING_ENABLED_KEY = "logging-enabled-key";

// Used to access Fused Location API,
// see https://developer.android.com/google/play-services/location.html
Expand Down Expand Up @@ -212,6 +213,9 @@ private void updateValuesFromBundle(Bundle savedInstanceState) {
if (savedInstanceState.keySet().contains(LAST_WIFI_SCAN_TIME_STRING_KEY)) {
lastWifiScanTime = new Date(savedInstanceState.getLong(LAST_WIFI_SCAN_TIME_STRING_KEY));
}
if (savedInstanceState.keySet().contains(LOGGING_ENABLED_KEY)) {
loggingEnabled = savedInstanceState.getBoolean(LOGGING_ENABLED_KEY);
}
updateUI();
}
}
Expand Down Expand Up @@ -366,6 +370,7 @@ public void onConnectionSuspended(int cause) {
log.info("GoogleApiClient connection suspended, attempting reconnect");
googleApiClient.connect();
}

/**
* Stores activity data in the Bundle.
*/
Expand All @@ -378,6 +383,7 @@ public void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
if (lastWifiScanTime != null) {
savedInstanceState.putLong(LAST_WIFI_SCAN_TIME_STRING_KEY, lastWifiScanTime.getTime());
}
savedInstanceState.putBoolean(LOGGING_ENABLED_KEY, loggingEnabled);
super.onSaveInstanceState(savedInstanceState);
}

Expand Down

0 comments on commit 188ddd0

Please sign in to comment.