Commit 8ef8ff1d authored by Chris Scott's avatar Chris Scott

Transmit isMoving state from plugin->service in case setConfig is executed,...

Transmit isMoving state from plugin->service in case setConfig is executed, which must stop/start the service to apply the new config -- we don't want to put the service in stationary-mode if it's already in moving mode
parent 3b3a8959
......@@ -33,6 +33,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
private Boolean isEnabled = false;
private Boolean stopOnTerminate = false;
private Boolean isMoving = false;
private Intent backgroundServiceIntent;
......@@ -113,6 +114,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
JSONObject config = data.getJSONObject(0);
Log.i(TAG, "- configure: " + config.toString());
backgroundServiceIntent.putExtra("isMoving", isMoving);
if (config.has("distanceFilter")) {
backgroundServiceIntent.putExtra("distanceFilter", (float) config.getInt("distanceFilter"));
}
......@@ -156,7 +158,6 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
public void onPause(boolean multitasking) {
Log.i(TAG, "- onPause");
if (isEnabled) {
//setPace(isMoving);
EventBus.getDefault().post(new PausedEvent(true));
}
}
......@@ -176,10 +177,12 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin {
result.setKeepCallback(true);
if (location instanceof StationaryLocation) {
isMoving = false;
if (stationaryCallback != null) {
runInBackground(stationaryCallback, result);
}
} else {
isMoving = true;
result.setKeepCallback(true);
runInBackground(locationCallback, result);
}
......
......@@ -133,6 +133,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
activityRecognitionInterval = intent.getIntExtra("activityRecognitionInterval", 60000);
stopTimeout = intent.getLongExtra("stopTimeout", 0);
forceReload = intent.getBooleanExtra("forceReload", false);
isMoving = intent.getBooleanExtra("isMoving", false);
// HTTP Configuration
url = intent.getStringExtra("url");
......@@ -157,6 +158,7 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
Log.i(TAG, " stopTimeout: " + stopTimeout);
Log.i(TAG, " stopOnTerminate: " + stopOnTerminate);
Log.i(TAG, " forceReload: " + forceReload);
Log.i(TAG, " isMoving: " + isMoving);
Log.i(TAG, "----------------------------------------");
// For debug sounds, turn on ToneGenerator.
......@@ -203,7 +205,9 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
Intent locationIntent = new Intent(this, LocationService.class);
locationUpdatePI = PendingIntent.getService(this, 0, locationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
setPace(isMoving);
// Start monitoring ARS
if (googleApiClient.isConnected()) {
requestActivityUpdates();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment