Added location looper thread
This commit is contained in:
parent
1a230ab3d3
commit
cb556beb2b
1 changed files with 5 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -32,6 +33,8 @@ public class LocationServiceHelperImpl extends LocationServiceHelper {
|
|||
|
||||
private final OsmandApplication app;
|
||||
|
||||
private final HandlerThread mHandlerThread = new HandlerThread("LocationServiceHelperThread");
|
||||
|
||||
// FusedLocationProviderClient - Main class for receiving location updates.
|
||||
private final FusedLocationProviderClient fusedLocationProviderClient;
|
||||
|
||||
|
@ -46,6 +49,7 @@ public class LocationServiceHelperImpl extends LocationServiceHelper {
|
|||
|
||||
public LocationServiceHelperImpl(@NonNull OsmandApplication app) {
|
||||
this.app = app;
|
||||
mHandlerThread.start();
|
||||
|
||||
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(app);
|
||||
|
||||
|
@ -100,7 +104,7 @@ public class LocationServiceHelperImpl extends LocationServiceHelper {
|
|||
// request location updates
|
||||
try {
|
||||
fusedLocationProviderClient.requestLocationUpdates(
|
||||
fusedLocationRequest, fusedLocationCallback, Looper.myLooper());
|
||||
fusedLocationRequest, fusedLocationCallback, mHandlerThread.getLooper());
|
||||
} catch (SecurityException e) {
|
||||
LOG.debug("Location service permission not granted");
|
||||
throw e;
|
||||
|
|
Loading…
Reference in a new issue