MapStateProvider
Interface for providing map state and controller to Android Auto.
This interface abstracts the mechanism by which Android Auto obtains the MapController and cached position from the phone application. It allows different applications to implement their own state sharing mechanism.
Purpose
Decoupling: Separates Android Auto module from specific app implementations
Flexibility: Apps can use Hilt, manual injection, or other DI frameworks
Reusability: The same Android Auto module works with different apps
Usage
Applications should implement this interface to provide the MapController and cached position when Android Auto requests them:
class MyMapStateProvider : MapStateProvider {
private var mapController: MapController? = null
private var cachedPosition: GeoPoint? = null
override fun getMapController(): MapController? = mapController
override fun getCachedInitialPosition(): GeoPoint? = cachedPosition
override fun hasMapController(): Boolean = mapController != null
fun setMapController(controller: MapController?) {
mapController = controller
}
fun setCachedInitialPosition(position: GeoPoint?) {
cachedPosition = position
}
}See also
Inheritors
Functions
Gets the cached initial position for instant map centering.
Gets the MapController for controlling the map from Android Auto.
Checks if a MapController is available.