MΓ³dulo 17 Β· Foreground Location Service β LecciΓ³n 3 de 4 Β· ~8 min
Stream fixes with FusedLocationProvider
The same FusedLocationProviderClient, running inside the service
Module 11 called FusedLocationProviderClient.requestLocationUpdates from a ViewModel, tied to whatever screen was on top. Here the exact same API runs inside the foreground service instead β the fixes keep flowing no matter what's on screen, because the service, not the screen, owns the subscription.
A LocationRequest still configures the stream: Priority.PRIORITY_HIGH_ACCURACY for the best fix the device can produce, and an interval in milliseconds for how often to check. Ties back to module 13's callbackFlow β wrapping requestLocationUpdates's callback-based API in a callbackFlow turns fixes into a Flow<Location> the rest of the service (and eventually the socket-publish code from module 11) can collect like any other stream.