AndroidLocationBackend

An Android location implementation discovered through ServiceLoader.

An installed and available backend supplies the providers that createDefaultLocationProvider and createDefaultOrientationProvider create; the framework providers remain the default otherwise. When several backends are available, the highest priority wins, and equal priorities resolve to the first id in lexicographic order. A ServiceConfigurationError, a LinkageError, or an exception while loading or checking a backend maps LocationProvider.backendAvailability to LocationBackendAvailability.Misconfigured. The installed backend documents its own availability conditions.

Properties

Link copied to clipboard
abstract val id: String

A stable name used in diagnostics and to break priority ties.

Link copied to clipboard
open val priority: Int

The precedence of this backend when several are available. The backend with the highest priority supplies the default providers. Backends ship with priority 0; declare a higher value for a backend that is a better fit on its own hardware, or a negative value for a last resort.

Functions

Link copied to clipboard

Creates this backend's location provider.

Link copied to clipboard
open fun createOrientationProvider(context: Context, updateInterval: Duration, coroutineScope: CoroutineScope): OrientationProvider?

Creates this backend's orientation provider, or returns null so the default framework orientation provider is used. coroutineScope shares the provider's orientation flow.

Link copied to clipboard
abstract fun isAvailable(context: Context): Boolean

Whether this backend can run on the current device.