BaseGuidanceProviderAdapter

abstract class BaseGuidanceProviderAdapter(scope: CoroutineScope, iconsRenderedForDarkMode: Boolean = false) : GuidanceProvider

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

scope

CoroutineScope for state observation (typically viewModelScope)

iconsRenderedForDarkMode

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

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, iconsRenderedForDarkMode: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val guidanceState: StateFlow<AAGuidanceState>

Public StateFlow of the current guidance state. Collected by Android Auto navigation screens to update the NavigationTemplate.

Link copied to clipboard
open override val isGuidanceActive: StateFlow<Boolean>

Public StateFlow indicating whether guidance is currently active.

Functions

Link copied to clipboard

Checks if the destination has been reached.

Link copied to clipboard
open fun isMuted(): Boolean

Checks if voice guidance is currently muted.

Link copied to clipboard
abstract fun recenter()

Recenters the map on the current position with navigation tracking.

Link copied to clipboard

Sets the event listener for navigation lifecycle callbacks.

Link copied to clipboard
abstract fun startNavigation()

Starts turn-by-turn navigation with the currently selected route.

Link copied to clipboard
abstract fun stopNavigation()

Stops the current navigation session.

Link copied to clipboard
abstract fun toggleMute()

Toggles voice guidance mute state.