I am trying to create an Android application that continuously logs device location data in realtime while the device screen is off. My code works correctly with Android 6.0 and
I had the same issue and I have found a working solution. In order to listen to location updates, you should NOT call this method:
public Task requestLocationUpdates (LocationRequest request,
LocationCallback callback, Looper looper)
You should use a pending intent instead of a callback, i.e. you should call the method:
public Task requestLocationUpdates (LocationRequest request,
PendingIntent callbackIntent)
Checkout the link to read more: https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient.html#requestLocationUpdates(com.google.android.gms.location.LocationRequest, android.app.PendingIntent)