public abstract class Screen
extends Object implements LifecycleOwner


A Screen has a Lifecycle and provides the mechanism for the app to send Templates to display when the Screen is visible. Screen instances can also be pushed and popped to and from a Screen stack, which ensures they adhere to the template flow restrictions (see onGetTemplate() for more details on template flow).

The Screen class can be used to manage individual units of business logic within a car app. A Screen is closely tied to the CarAppService it is a part of, and cannot be used without it. Though Screen defines its own lifecycle (see getLifecycle()), that lifecycle is dependent on its CarAppService: if the car app service is stopped, no screens inside of it can be started; when the car app service is destroyed, all screens will be destroyed.

Screen objects are not thread safe and all calls should be made from the same thread.


Protected constructors

Screen(CarContext carContext)

Public methods

final void finish()

Removes this screen from the stack, which will move its lifecycle state down to Lifecycle.State.DESTROYED.

final CarContext getCarContext()

Returns the CarContext of the CarAppService.

final Lifecycle getLifecycle()

Returns this screen's lifecycle.

String getMarker()

Retrieves the marker that has been set for this screen, or null if one has not been set.

final ScreenManager getScreenManager()

Returns the ScreenManager to use for pushing/removing screens.

final void invalidate()

Requests the current template to be invalidated, which eventually triggers a call to onGetTemplate() to get the new template to display.

abstract Template onGetTemplate()

Returns the Template to present in the car screen.

void setMarker(String marker)

Updates the marker for this screen.

void setResult(Object result)

Sets the result that will be sent to the OnScreenResultListener that was given when pushing this screen onto the stack using ScreenManager.pushForResult(Screen, OnScreenResultListener).

Inherited methods