AANavigationCoordinator

class AANavigationCoordinator(carContext: CarContext, screenFactory: AAScreenFactory, additionalTransitions: Map<Pair<AANavigationState, AANavigationAction>, AANavigationState> = emptyMap())

Coordinator managing Android Auto screen navigation using a state machine.

This class serves as the single point of control for all screen navigation in Android Auto. It uses AANavigationStateMachine to validate transitions before executing them, ensuring the screen stack remains consistent with the navigation state.

Screen instantiation is delegated to AAScreenFactory, allowing each app to provide its own screen implementations without the SDK knowing about concrete screen types.

Responsibilities

  1. Validate Navigation: Uses state machine to check if a navigation is valid

  2. Execute Navigation: Performs the actual screen push/pop via ScreenManager

  3. Coordinate Callbacks: Notifies phone app of relevant state changes

  4. Provide State: Exposes current state for UI updates

Usage

val factory = MyScreenFactory()
val coordinator = AANavigationCoordinator(carContext, factory)

coordinator.openSearch() // Validates and pushes SearchScreen
coordinator.selectDestination("Paris") // Validates and pushes RoutePreviewScreen
coordinator.startNavigation("Paris", false) // Validates and pushes NavigationScreen

Parameters

carContext

The CarContext from the Android Auto session

screenFactory

Factory for creating app-specific screen instances

additionalTransitions

Additional state machine transitions for custom screens. Merged with built-in defaults. See AANavigationStateMachine for details.

See also

Constructors

Link copied to clipboard
constructor(carContext: CarContext, screenFactory: AAScreenFactory, additionalTransitions: Map<Pair<AANavigationState, AANavigationAction>, AANavigationState> = emptyMap())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Observable current navigation state.

Functions

Link copied to clipboard

Cancels route preview and returns to map view.

Link copied to clipboard

Checks if a back navigation is valid from the current state.

Link copied to clipboard

Gets the list of valid actions from the current state.

Link copied to clipboard

Handles back button press.

Link copied to clipboard

Navigates to a custom screen using a custom action.

Link copied to clipboard

Called when Android Auto connects.

Link copied to clipboard

Called when Android Auto disconnects.

Link copied to clipboard

Opens the search screen from MapView.

Link copied to clipboard
fun reportState(state: AANavigationState, reason: String)

Forces the state machine to a specific state without screen changes.

Link copied to clipboard
fun reset()

Resets the coordinator to initial state.

Link copied to clipboard
fun selectDestination(destinationTitle: String): Boolean

Selects a destination and opens route preview.

Link copied to clipboard
fun startNavigation(destinationTitle: String, useDemoMode: Boolean = false, isSyncPush: Boolean = false): Boolean

Starts navigation from route preview.

Link copied to clipboard

Stops navigation and returns to map view.

Link copied to clipboard
fun syncToPhoneState(phoneState: AANavigationState, destinationTitle: String = "", useDemoMode: Boolean = false)

Synchronizes the navigation state to match the phone's equivalent state.