Google berkomitmen untuk mendorong terwujudnya keadilan ras bagi komunitas Kulit Hitam. Lihat caranya.

WindowManager

class WindowManager
kotlin.Any
   ↳ androidx.window.WindowManager

Main interaction point with the WindowManager library. An instance of this class allows polling the current state of the device and display, and registering callbacks for changes in the corresponding states.

Summary

Public constructors
<init>(@NonNull context: Context, @Nullable windowBackend: WindowBackend?)

Get an instance of the class initialized with and connected to the provided Context.

Public methods
DeviceState

Get the current device state.

WindowLayoutInfo

Get current window layout information for the associated Context.

Unit
registerDeviceStateChangeCallback(@NonNull executor: Executor, @NonNull callback: Consumer<DeviceState!>)

Register a callback for device state changes.

Unit
registerLayoutChangeCallback(@NonNull executor: Executor, @NonNull callback: Consumer<WindowLayoutInfo!>)

Register a callback for layout changes of the window of the current visual Context.

Unit

Unregister a callback for device state changes.

Unit

Unregister a callback for window layout changes of the window.

Public constructors

<init>

WindowManager(
    @NonNull context: Context,
    @Nullable windowBackend: WindowBackend?)

Get an instance of the class initialized with and connected to the provided Context. All methods of this class will return information that is associated with this visual context.

Parameters
context Context: A visual context, such as an Activity or a ContextWrapper around one, to use for initialization.
windowBackend WindowBackend?: Backing server class that will provide information for this instance. Pass a custom WindowBackend implementation for testing, or null to use the default implementation.

Public methods

getDeviceState

@NonNull fun getDeviceState(): DeviceState

Get the current device state.

See Also

getWindowLayoutInfo

@NonNull fun getWindowLayoutInfo(): WindowLayoutInfo

Get current window layout information for the associated Context. Must be called only after the it is attached to the window and the layout pass has happened.

registerDeviceStateChangeCallback

fun registerDeviceStateChangeCallback(
    @NonNull executor: Executor,
    @NonNull callback: Consumer<DeviceState!>
): Unit

Register a callback for device state changes.

registerLayoutChangeCallback

fun registerLayoutChangeCallback(
    @NonNull executor: Executor,
    @NonNull callback: Consumer<WindowLayoutInfo!>
): Unit

Register a callback for layout changes of the window of the current visual Context. Must be called only after the it is attached to the window.

unregisterDeviceStateChangeCallback

fun unregisterDeviceStateChangeCallback(@NonNull callback: Consumer<DeviceState!>): Unit

Unregister a callback for device state changes.

unregisterLayoutChangeCallback

fun unregisterLayoutChangeCallback(@NonNull callback: Consumer<WindowLayoutInfo!>): Unit

Unregister a callback for window layout changes of the window.