I've been running into this problem for a couple months now. My android app uses a foreground service (modeled on this to track the location of for brief periods. This was working well through Android P, but with the release of Android 10/Q, the foreground service stops sending updates for a period of ten minutes before beginning to again update like it should. These circumstances are:
- Running on Android Q
- Configured to send batched location updates
- The app is placed in the background
Upon being backgrounded, the location updates will stop for a period of up to ten minutes before restarting and sending batched location updates appropriately. During this period the required foreground notification is still showing, and the service is running according to Android's OS. The only other odd behavior is that sometimes it will invoke the OnLocationAvailability callback of the LocationCallback, but it does this whether it's in the foreground or background.
Things I've done:
- Disabling batched location updates: This works to get consistent updates, but breaks another super cool part of my app. I'd prefer to get the OS working properly, instead.
- Adding both new Android Q manifest changes (ACCESS_BACKGROUND_PERMISSION and foregroundServiceType="location"). I did this as part of the Android Q update.
- Expanded my logging in the foreground service, which has been useless since it just waits for the FusedLocationProviderClient
How should I progress in debugging this? It's been hard to gain more visibility into the foreground service and the fusedLocationProviderClient. Alternatively, if anyone has run into this issue, I'd also appreciate your feedback.