Skip to content

Commit 35dadcd

Browse files
committed
Fixed another GoogleApiClient not connected error
* Added isConnected checks to all remaining usages.
1 parent 2632466 commit 35dadcd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/LocationGMS.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ public void onLocationChanged(Location location) {
302302
static class FusedLocationApiWrapper {
303303
@SuppressWarnings("MissingPermission")
304304
static PendingResult<Status> requestLocationUpdates(GoogleApiClient googleApiClient, LocationRequest locationRequest, LocationListener locationListener) {
305-
return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, locationListener);
305+
if (googleApiClient.isConnected())
306+
return LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, locationListener);
307+
return null;
306308
}
307309

308310
static PendingResult<Status> removeLocationUpdates(GoogleApiClient googleApiClient, LocationListener locationListener) {
@@ -313,11 +315,13 @@ static PendingResult<Status> removeLocationUpdates(GoogleApiClient googleApiClie
313315

314316
@SuppressWarnings("MissingPermission")
315317
static Location getLastLocation(GoogleApiClient googleApiClient) {
316-
return LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
318+
if (googleApiClient.isConnected())
319+
return LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
320+
return null;
317321
}
318322
}
319323

320-
static class LocationHandlerThread extends HandlerThread {
324+
private static class LocationHandlerThread extends HandlerThread {
321325
Handler mHandler = null;
322326

323327
LocationHandlerThread() {

0 commit comments

Comments
 (0)