androidandroid-auto

How to show navigation alert in NavigationTemplate (Android Auto)?


The NavigationTemplate documentation declares that "Navigation alerts" can be used to show temporary message with optional actions, etc.: https://developers.google.com/cars/design/create-apps/apps-for-drivers/templates/navigation-template#alerts

I could find Alert documentation: https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert

Or Alert.Builder documentation: https://developer.android.com/reference/kotlin/androidx/car/app/model/Alert.Builder

So I can successfully create an Alert like this:

val alert = Alert.Builder(
    MY_ALERT_ID, 
    CarText.Builder("My Alert").build(), 
    MY_ALERT_DURATION
).build()

However I cannot find any interface to be fed with this object. How can I display my alert?


Solution

  • https://developer.android.com/training/cars/apps/navigation#in-context-navigation has the details on how to build and show an alert!