Skip to content

UI Lifecycle

Overview

The lifecycle of the Screen and the UIElement is changing according to the state of the glasses.

For example, the SDK won't render the screen if the glasses are disconnected or their display is off.

Screen Lifecycle

The following diagram presents the Screen lifecycle:

Screen lifecycle callbacks:

Method Description
onCreate Is called when the screen is the topmost screen and the glasses are connected. Use this function to create your UI element and add them to the screen
onResume Is called when the screen is currently drawn on the glasses display. Use this function to start animations and to prepare your UI for its first draw
onUpdateUI Is called before each draw. Use this function to update your screen UI elements tree to their most updated state
draw (here the rendering pipeline is performed)
onPause Is called when a resumed becomes inactive: when the glasses are disconnected or the screen is not at the top of the screens stack or when the display turns off
onDestroy Is called when the screen is removed from the screens stack

UIElement Lifecycle

The following diagram presents the UIElement lifecycle:

UIElement lifecycle callbacks:

Method Description
onAttachedToScreen Is called when the UIElement is attached to a screen
onCreate Is called when the screen the UI element is attached to is created. Use this function to initialize the element content
onBeforeDraw Is called before each draw of the UIElement. Use this function to update your element to its most updated state
onLayout For advanced UI - Override this method to re-arrange your elements after their size were determined
onDraw For advanced usages. Override this function to draw information directly on the Canvas
onBeforeDetachFromScreen Is called just before the UIElement is detached from the screen. Use this function to clean resources

Did you know?

Our Development Resources provides a variety of samples to help you get started with application development.


Learn about the Rendering Pipeline