ScreenManager

public class ScreenManager
extends Object implements Manager

java.lang.Object
   ↳ androidx.car.app.ScreenManager


Manages the stack of Screens and their respective Lifecycles.

Summary

Public methods

int getStackSize()

Returns the current stack size.

Screen getTop()

Returns the Screen that is at the top of the stack.

void pop()

Pops the top Screen from the stack.

void popTo(String marker)

Removes screens from the top of the stack until a Screen which has the given marker is found, or the root has been reached.

void popToRoot()

Removes all screens from the stack until the root has been reached.

void push(Screen screen)

Pushes the screen to the stack.

void pushForResult(Screen screen, OnScreenResultListener onScreenResultListener)

Pushes a Screen, for which you would like a result from, onto the stack.

void remove(Screen screen)

Removes the screen from the stack.

Inherited methods

Public methods

getStackSize

public int getStackSize ()

Returns the current stack size.

Returns
int

getTop

public Screen getTop ()

Returns the Screen that is at the top of the stack.

Returns
Screen

Throws
NullPointerException if the method is called before a Screen has been pushed to the stack via push(Screen), or pushForResult(Screen, OnScreenResultListener), or returning a Screen from Session.onCreateScreen(Intent)
IllegalStateException if the current thread is not the main thread

pop

public void pop ()

Pops the top Screen from the stack.

If the top Screen is the only Screen in the stack, it will not be removed.

Throws
IllegalStateException if the current thread is not the main thread

popTo

public void popTo (String marker)

Removes screens from the top of the stack until a Screen which has the given marker is found, or the root has been reached.

The root Screen will not be popped.

Parameters
marker String

Throws
NullPointerException if marker is null
IllegalStateException if the current thread is not the main thread

popToRoot

public void popToRoot ()

Removes all screens from the stack until the root has been reached.

Throws
IllegalStateException if the current thread is not the main thread

push

public void push (Screen screen)

Pushes the screen to the stack.

If the screen pushed is already in the stack it will be moved to the top of the stack.

Parameters
screen Screen

Throws
NullPointerException if screen is null
IllegalStateException if the current thread is not the main thread

pushForResult

public void pushForResult (Screen screen, 
                OnScreenResultListener onScreenResultListener)

Pushes a Screen, for which you would like a result from, onto the stack.

When the given screen finishes, the onScreenResultCallback will receive a callback to OnScreenResultListener.onScreenResult(Object) with the result that the pushed screen set via Screen.setResult(Object).

Paramete