UiMediaScope


A receiver scope that provides access to the properties of the current media environment. This scope is used by mediaQuery to evaluate conditions based on the device and window state.

Summary

Nested types

Describes the kind of keyboard available.

Describes the precision of the available pointing devices.

Describes the posture of the window, typically on a foldable device.

Describes the typical distance between the user and the screen.

Public properties

Boolean

Whether the camera is supported on the current device.

Cmn
Boolean

Whether the microphone is supported on the current device.

Cmn
UiMediaScope.KeyboardKind

The type of keyboard currently available or connected.

Cmn
UiMediaScope.PointerPrecision

The highest-precision pointing device currently available.

Cmn
UiMediaScope.ViewingDistance

The typical distance between the user and the device screen.

Cmn
Dp

The current height of the application window.

Cmn
UiMediaScope.Posture

The current posture of the application window.

Cmn
Dp

The current width of the application window.

Cmn

Public properties

hasCamera

val hasCameraBoolean

Whether the camera is supported on the current device.

hasMicrophone

val hasMicrophoneBoolean

Whether the microphone is supported on the current device.

keyboardKind

val keyboardKindUiMediaScope.KeyboardKind

The type of keyboard currently available or connected.

This property prioritizes a physical keyboard connection (AnyKeyboard.Physical) over an on-screen soft keyboard (AnyKeyboard.Virtual). If neither is detected, it returns AnyKeyboard.None.

pointerPrecision

val pointerPrecisionUiMediaScope.PointerPrecision

The highest-precision pointing device currently available.

This property resolves the pointer type based on all connected input devices, prioritizing higher precision (e.g., PointerPrecision.Fine takes precedence over PointerPrecision.Coarse if both are present). See PointerPrecision for all possible values.

viewingDistance

val viewingDistanceUiMediaScope.ViewingDistance

The typical distance between the user and the device screen.

This property provides an estimate of the viewing distance, which can be useful for adjusting UI scale, content density, or hit target sizes for better ergonomics and readability.

Note that this is a broad categorization and does not represent a precise physical measurement. It is based on the device type and its typical usage context.

windowHeight

val windowHeightDp

The current height of the application window.

windowPosture

val windowPostureUiMediaScope.Posture

The current posture of the application window.

This reflects how the window is laid out on the screen, which may be affected by the device's physical state. See Posture for possible values.

windowWidth

val windowWidthDp

The current width of the application window.