Skip to content

Commit 6c762d3

Browse files
authored
Only remove location updates when connected (#348)
1 parent c64e2aa commit 6c762d3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

mapbox/app/src/main/java/com/mapbox/services/android/testapp/location/GoogleLocationEngine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public void requestLocationUpdates() {
122122

123123
@Override
124124
public void removeLocationUpdates() {
125-
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
125+
if (googleApiClient.isConnected()) {
126+
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
127+
}
126128
}
127129

128130
@Override

mapbox/libandroid-services/src/main/java/com/mapbox/services/android/location/LostLocationEngine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ public void requestLocationUpdates() {
111111

112112
@Override
113113
public void removeLocationUpdates() {
114-
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
114+
if (lostApiClient.isConnected()) {
115+
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
116+
}
115117
}
116118

117119
@Override

0 commit comments

Comments
 (0)