Commit a9c1c12c authored by Chris Scott's avatar Chris Scott

Merge branch 'bugs' into edge

parents 6099e4b8 74592aa0
...@@ -123,7 +123,10 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl ...@@ -123,7 +123,10 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
instance = this; instance = this;
EventBus.getDefault().register(this); EventBus eventBus = EventBus.getDefault();
if (!eventBus.isRegistered(this)) {
eventBus.register(this);
}
// Load config settings // Load config settings
SharedPreferences settings = getSharedPreferences(TAG, 0); SharedPreferences settings = getSharedPreferences(TAG, 0);
...@@ -348,10 +351,12 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl ...@@ -348,10 +351,12 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
startTone("long_beep"); startTone("long_beep");
// set our stationaryLocation // set our stationaryLocation
stationaryLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); stationaryLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
if (stationaryLocation != null) {
EventBus.getDefault().post(new StationaryLocation(stationaryLocation)); EventBus.getDefault().post(new StationaryLocation(stationaryLocation));
} }
} }
} }
}
/** /**
* Translates a number representing desired accuracy of GeoLocation system from set [0, 10, 100, 1000]. * Translates a number representing desired accuracy of GeoLocation system from set [0, 10, 100, 1000].
* 0: most aggressive, most accurate, worst battery drain * 0: most aggressive, most accurate, worst battery drain
...@@ -579,10 +584,13 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl ...@@ -579,10 +584,13 @@ public class BackgroundGeolocationService extends Service implements GoogleApiCl
private void cleanUp() { private void cleanUp() {
instance = null; instance = null;
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
if (googleApiClient != null && googleApiClient.isConnected()) {
removeActivityUpdates(); removeActivityUpdates();
removeLocationUpdates(); removeLocationUpdates();
googleApiClient.disconnect(); googleApiClient.disconnect();
} }
}
/** /**
* Convert a Location instance to JSONObject * Convert a Location instance to JSONObject
......
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