Reputation: 19214
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.
Upvotes: 3
Views: 2253
Reputation: 1959
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
Upvotes: 3
Reputation: 36
Currently the app only get's location updates if a foreground service is running and the activity was in foreground. Then you can put the app into background or turn the screen off and it keeps getting location updates.
If the foreground service is launched after the app was put into background, e.g. by a BroadcastReceiver, then it doesn't get location updates.
As a workaround we would have to request background location permissions.
Seems that this is an open issue for Android 11: https://issuetracker.google.com/issues/158814176
Upvotes: 1