track

open suspend override fun track(request: LocationRequest): Flow<Location>

Start tracking the location.

Either collect the returned flow or use locationUpdates to receive location updates. If you call stopTracking, the flow will no longer emit values until track is called again. But the flow won't be cancelled, so you should cancel it if you no longer need it.

Note: The returned flow will not throw an exception, but this function will throw an exception if location services aren't available or the location permission isn't granted.

Return

A flow of location updates.

Parameters

request

The location request details.

Throws

If location services aren't available.

If there is an error getting the location.

If the location permission isn't granted.