API reference

Display Interface

Extends Closeable
Interface for managing display capabilities attached to a Session.
A Display handles rendering content on Meta glasses. Displays are created via Session.addDisplay and automatically stopped when the parent session stops (cascading stop). They can also be stopped individually via Display.stop or removed via Session.removeDisplay.

See Also

  • Session.addDisplay to create a display capability
  • DisplayState for display lifecycle states

Signature

interface Display : Closeable

Properties

state : StateFlow<DisplayState>
[Get]
The current state of the display capability.
State transitions:
  • STOPPED -> STARTING -> STARTED (when display connects)
  • STARTED -> STOPPING -> STOPPED (on device disconnect or removal)
  • Any state -> STOPPING -> STOPPED -> CLOSED (on close/stop)
Signature
abstract val state: StateFlow<DisplayState>

Methods

clearDisplay ()
Clears content currently rendered on the wearable display.
This removes the current display content without stopping the display capability or detaching it from the parent session. After a successful clear, the same Display can render new content by calling Display.sendContent.
Signature
abstract suspend fun clearDisplay(): DatResult<Boolean, DisplayError>
Returns
DatResult  A DatResult indicating success or failure with a DisplayError.
close ()
Signature
abstract override fun close()
sendContent ( content )
Builds and sends content to the wearable device using the Display Views DSL.
The content block provides a ContentScope where you can build layouts using flexBox or render video using video. Each call to sendContent replaces any previously displayed content.
Example:
display.sendContent {
    flexBox(direction = Direction.COLUMN, gap = 8) {
        text("Hello, Glasses!", style = TextStyle.HEADING)
        button(label = "Dismiss") { /* onClick */}
    }
}

Signature
abstract suspend fun sendContent(content: ContentScope.() -> Unit): DatResult<Boolean, DisplayError>
Parameters
content: Function1  The builder block to construct the display content.
Returns
DatResult  A DatResult indicating success or failure with a DisplayError.
stop ()
Stops this display, releasing its resources and detaching it from the parent session.
After calling Display.stop, the display is invalidated and cannot be reused. Calling Display.stop on an already-stopped display is a no-op. Display.close delegates to Display.stop for Closeable compatibility.
Signature
abstract fun stop()