This terminology and these concepts are used throughout this section.
CarAppServiceCarAppServiceis an abstractServiceclass that your app must implement and export to be discovered and managed by the host. Your app'sCarAppServiceusescreateHostValidatorto validate that a host connection can be trusted and, subsequently, usesonCreateSessionto provideSessioninstances for each connection.- Host
The host is the backend component that implements the functionality offered by the library's APIs so your app can run in the car. The host provides a range of services, from discovering your app and managing its lifecycle to converting your models into views and notifying your app of user interactions.
On mobile devices, this host is implemented by Android Auto. On Android Automotive OS, this host is installed as a system app.
- Models and templates
The user interface is represented by a graph of model objects you can arrange together in different ways, per the template to which they belong. Templates are a subset of the models that act as a root in the graphs.
Models include the information to be displayed to the user in the form of text and images as well as attributes to configure aspects of the visual appearance of such information. For example, text colors or image sizes.
The host converts the models to views that meet driver distraction standards and address details such as the variety of car screen factors and input modalities.
ScreenScreenis a class provided by the library that apps implement to manage the user interface visible to the user.A
Screenhas a lifecycle and is used by the app to send the template to display when the screen is visible.Screeninstances can also be pushed and popped to and from aScreenstack to confirm they meet template flow restrictions.SessionSessionis an abstract class that your app must implement and return usingCarAppService.onCreateSession. ASessionserves as the entry point to display information on the car screen.Sessionhas a lifecycle that informs the current state of your app on the car screen, such as when your app is visible or hidden.When a
Sessionis started, such as when the app is first launched, the host uses theonCreateScreenmethod to ask which initialScreento display.- Template restrictions
Different templates enforce restrictions in the content of their models. For example, list templates impose limits on the number of items that can be presented to the user.
Templates also have restrictions in the way they can be connected to form the flow of a task. For example, an app can push up to five templates to the screen stack. To learn more, see Template restrictions.