LocationCollector

A device collector that gathers GPS location information from the device.

This collector attempts to retrieve the device's last known location using Google Play Services. It handles location permission requests automatically by launching a permission request activity when necessary. The collection process is asynchronous and may prompt the user for permissions.

Parameters

timeout

The maximum time to wait for permission result in milliseconds (default 30000ms). Can be adjusted based on expected user interaction time.

Required Permissions:

Privacy Note: Location data is sensitive personal information. Ensure proper user consent and privacy policy disclosure before collecting location data.

See also

for the data structure containing latitude and longitude coordinates

Constructors

Link copied to clipboard
constructor(timeout: Long = 30000)

Properties

Link copied to clipboard
open override val key: String
Link copied to clipboard
open override val serializer: KSerializer<LocationInfo>

Functions

Link copied to clipboard
open suspend override fun collect(): LocationInfo?

Collects the device's current location information asynchronously.