Skip to content

Commit

Permalink
fix #4 crash GoogleApiClient
Browse files Browse the repository at this point in the history
  • Loading branch information
netodevel committed Jun 16, 2017
1 parent 9938627 commit 6f4bd5c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ protected void createLocationRequest() {

protected void startLocationUpdates() {
try {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
if (mGoogleApiClient.isConnected()) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
}
} catch (SecurityException ex) {
}
}
Expand All @@ -119,7 +121,9 @@ private void sendLocationBroadcast(Location sbLocationData) {
}

protected void stopLocationUpdates() {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
if (mGoogleApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
}

@Override
Expand Down

0 comments on commit 6f4bd5c

Please sign in to comment.