Foreground service not receiving location updates in Android 7.0+ when screen is off

I've spent the past week trying to get Location Services in Foreground. Finally got it working by including this in the manifest.

android:foregroundServiceType="location"

I hope this can help someone in the future!


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<Void> 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<Void> 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)