Interface

AmbientModeManager

Source set: Android
public interface AmbientModeManager

Properties

currentAmbientMode

Source set: Android
public val currentAmbientMode: AmbientMode

The current state of the display, which is either AmbientMode.Interactive or AmbientMode.Ambient.

This property should be backed by Compose's Snapshot State system. Reading this value inside a composable function should automatically subscribe the composable to state changes and trigger a recomposition when the ambient mode changes.

Functions

withAmbientTick

public suspend fun withAmbientTick(block: () -> Unit)

Suspends the calling coroutine and waits for the next delivered "ambient tick".

When the device is in AmbientMode.Ambient, the system only provides updates at infrequent intervals (typically once per minute) to preserve battery life. This function allows a coroutine to pause and resume execution specifically when that tick is received.

The provided block will be executed synchronously when the tick occurs, and any state updates performed within it will be reflected on the ambient screen.

This function should typically be used within a looping LaunchedEffect that runs only when currentAmbientMode is AmbientMode.Ambient.

Parameters

block The state update logic to execute immediately upon receiving the ambient tick.

Last updated: