BaseGuidanceProviderAdapter
Base class for adapters that bridge app-specific guidance ViewModels to the GuidanceProvider interface used by Android Auto screens.
This base class handles the generic infrastructure that any MSDK client's guidance adapter would need:
State flow management (collecting source state and exposing to AA)
Navigation lifecycle detection (started, ended, destination reached)
Event listener notification
Icon processing utilities (PNG encoding, dark background inversion, caching)
How to Use
Subclass and implement the abstract members. Call startObservation in your subclass's init block — it cannot be called from the base class constructor because subclass properties are not yet initialized at that point.
class MyGuidanceAdapter(
private val viewModel: MyGuidanceViewModel,
scope: CoroutineScope
) : BaseGuidanceProviderAdapter(scope) {
init {
startObservation() // Must be called here, after viewModel is assigned
}
override fun observeGuidanceState(): Flow<AAGuidanceState> {
return myViewModelStateFlow.map { state ->
AAGuidanceState(
instruction = state.instruction,
maneuverIcon = processIconForAA(state.icon, isChained = false),
// ... other field mappings
)
}
}
override fun startNavigation() { viewModel.start() }
override fun stopNavigation() { viewModel.stop() }
override fun toggleMute() { viewModel.toggleMute() }
override fun recenter() { viewModel.recenter() }
}Icon Processing
The AA NavigationTemplate uses a dark card background. If the app renders maneuver icons for light mode (black lines on transparent), they become invisible on AA's dark surface. Use processIconForAA in your observeGuidanceState implementation to handle inversion and caching automatically.
Parameters
CoroutineScope for state observation (typically viewModelScope)
Whether the app's maneuver icons are already rendered with light colors for dark backgrounds. If false (default), icons will be RGB-inverted before sending to AA.
See also
Properties
Functions
Checks if the destination has been reached.
Sets the event listener for navigation lifecycle callbacks.
Starts turn-by-turn navigation with the currently selected route.
Stops the current navigation session.
Toggles voice guidance mute state.