Skip to content

Commit 1f08fcd

Browse files
committed
Add Looper prepare to requestLocationUpdates
* Add Looper null check followed by Looper prepare to avoid null pointer exception due to unprepared thread
1 parent a27c12c commit 1f08fcd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import android.location.Location;
3131
import android.os.Bundle;
32+
import android.os.Looper;
3233

3334
import androidx.annotation.NonNull;
3435

@@ -194,6 +195,8 @@ static class FusedLocationApiWrapper {
194195
static void requestLocationUpdates(GoogleApiClient googleApiClient, LocationRequest locationRequest, LocationListener locationListener) {
195196
try {
196197
synchronized (GMSLocationController.syncLock) {
198+
if (Looper.myLooper() == null)
199+
Looper.prepare();
197200
if (googleApiClient.isConnected())
198201
LocationServices.FusedLocationApi.requestLocationUpdates(googleApiClient, locationRequest, locationListener);
199202
}

0 commit comments

Comments
 (0)