WindowInfoController


abstract class WindowInfoController


An interface to interact with Window properties and layout.

Summary

Public companion functions

WindowInfoController

Gets an instance of WindowInfoController for the given Context.

Public functions

abstract Unit
@MainThread
requestVisualState(
    context: @UiContext Context,
    request: VisualStateRequest
)

Dispatches a request to modify the visual state of the window.

Public companion functions

getInstance

Added in 1.6.0-alpha03
fun getInstance(context: @UiContext Context): WindowInfoController

Gets an instance of WindowInfoController for the given Context.

Public functions

requestVisualState

Added in 1.6.0-alpha03
@MainThread
abstract fun requestVisualState(
    context: @UiContext Context,
    request: VisualStateRequest
): Unit

Dispatches a request to modify the visual state of the window.

The requested state is evaluated against the task hierarchy by the system. It is automatically cleared when the requesting task is no longer active.

Note that this is a request; it is up to the system to determine whether the requested visual state will be respected based on device policies and hardware capabilities. Applications should observe WindowLayoutInfo.engagementModes to observe the actual applied state.

Note: Throws IllegalStateException if not called on the main thread, or if the provided context is not a UI context (e.g. an Application context).

On Android 16 (API level 37) and above, this request is forwarded to the system. On lower API levels, calling this method is a no-op.

Parameters
context: @UiContext Context

The Context used to dispatch the request.

request: VisualStateRequest

The VisualStateRequest containing the desired visual state.