The second Android 11 Developer Preview is now available, test it out and share your feedback.

ExtensionWindowBackend

public final class ExtensionWindowBackend
extends Object implements WindowBackend

java.lang.Object
   ↳ androidx.window.ExtensionWindowBackend


Default implementation of WindowBackend that uses a combination of platform APIs and device-dependent OEM extensions.

Summary

Public methods

DeviceState getDeviceState()

Get the current device state.

static ExtensionWindowBackend getInstance(Context context)

Get the shared instance of the class.

WindowLayoutInfo getWindowLayoutInfo(Context context)

Get current window layout information for the provided Context.

void registerDeviceStateChangeCallback(Executor executor, Consumer<DeviceState> callback)

Register a callback for device state changes.

void registerLayoutChangeCallback(Context context, Executor executor, Consumer<WindowLayoutInfo> callback)

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

void unregisterDeviceStateChangeCallback(Consumer<DeviceState> callback)

Unregister a callback for device state changes.

void unregisterLayoutChangeCallback(Consumer<WindowLayoutInfo> callback)

Unregister a callback for window layout changes of the Context window.

Inherited methods

Public methods

getDeviceState

public DeviceState getDeviceState ()

Get the current device state.

Returns
DeviceState

getInstance

public static ExtensionWindowBackend getInstance (Context context)

Get the shared instance of the class.

Parameters
context Context

Returns
ExtensionWindowBackend

getWindowLayoutInfo

public WindowLayoutInfo getWindowLayoutInfo (Context context)

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

Parameters
context Context

Returns
WindowLayoutInfo

registerDeviceStateChangeCallback

public void registerDeviceStateChangeCallback (Executor executor, 
                Consumer<DeviceState> callback)

Register a callback for device state changes.

Parameters
executor Executor

callback Consumer

registerLayoutChangeCallback

public void registerLayoutChangeCallback (Context context, 
                Executor executor, 
                Consumer<WindowLayoutInfo> callback)

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.

Parameters
context Context

executor Executor

callback Consumer

unregisterDeviceStateChangeCallback

public void unregisterDeviceStateChangeCallback (Consumer<DeviceState> callback)

Unregister a callback for device state changes.

Parameters
callback Consumer

unregisterLayoutChangeCallback

public void unregisterLayoutChangeCallback (Consumer<WindowLayoutInfo> callback)

Unregister a callback for window layout changes of the Context window.

Parameters
callback Consumer