Search code examples
androidservicelocationandroid-11

Location Updates in Android 11


My app traces location updates in foreground services periodically started from background and is working properly in Android Q after adding android:foregroundServiceType="location" but in Android 11 beta it does not receive locations anymore.

Is this manner new in 11 or just a bug? I did not see anything in the documents.


Solution

  • Starting with Android 11, a foreground "location" service is no longer enough to get background location updates. We now need to request ACCESS_BACKGROUND_LOCATION, if the foreground service is started in the background (such as a broadcast receiver):

    https://developer.android.com/about/versions/oreo/background-location-limits

    Even worse, you have to request ACCESS_BACKGROUND_LOCATION separately from the other location permissions, or it won't work:

    https://developer.android.com/about/versions/11/privacy/location