CarContext

public class CarContext
extends ContextWrapper

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ androidx.car.app.CarContext


The CarContext class is a ContextWrapper subclass accessible to your CarAppService and Screen instances, which provides access to car services such as the ScreenManager for managing the screen stack, the AppManager for general app-related functionality such as accessing a surface for drawing your navigation app's map, and the NavigationManager used by turn-by-turn navigation apps to communicate navigation metadata and other navigation-related events with the host. See Access the navigation templates for a comprehensive list of library functionality available to navigation apps.

Whenever you use a CarContext to load resources, the following configuration elements come from the car screen's configuration, and not the phone:

  • Screen width.
  • Screen height.
  • Screen pixel density (DPI).
  • Night mode (See isDarkMode()).

Please refer here, on how to use configuration qualifiers in your resources.

Summary

Constants

String ACTION_NAVIGATE

Standard action for navigating to a location.

String APP_SERVICE

Manages all app events such as invalidating the UI, showing a toast, etc.

String CAR_SERVICE

Internal usage only.

String CONSTRAINT_SERVICE

Manages constraints for the app as enforced by the connected host.

String EXTRA_START_CAR_APP_BINDER_KEY

Key for including a IStartCarApp in the notification Intent, for starting the app if it has not been opened yet.

String HARDWARE_SERVICE

Manages access to androidx.car.app.hardware properties, sensors and actions.

String NAVIGATION_SERVICE

Manages all navigation events such as starting navigation when focus is granted, abandoning navigation when focus is lost, etc.

String SCREEN_SERVICE

Manages the screens of the app, including the screen stack.

Inherited constants