Android 12 Developer Preview is here! Try it out, and give us your feedback!

WindowBackend

public interface WindowBackend

androidx.window.WindowBackend


Backing interface for WindowManager instances that server as the default information supplier.

Summary

Public methods

abstract DeviceState getDeviceState()

This method is deprecated. will be removed in the next alpha

abstract WindowLayoutInfo getWindowLayoutInfo(Context context)

This method is deprecated. will be removed in the next alpha

abstract WindowLayoutInfo getWindowLayoutInfo(Activity activity)

This method is deprecated. will be removed in the next alpha

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

Registers a callback for device state changes.

abstract void registerLayoutChangeCallback(Activity activity, Executor executor, Consumer<WindowLayoutInfo> callback)

Registers a callback for layout changes of the window for the supplied Activity.

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

This method is deprecated. will be removed in the next alpha.

abstract void unregisterDeviceStateChangeCallback(Consumer<DeviceState> callback)

Unregisters a callback for device state changes.

abstract void unregisterLayoutChangeCallback(Consumer<WindowLayoutInfo> callback)

Unregisters a callback for window layout changes of the Activity window.

Public methods

getDeviceState

public abstract DeviceState getDeviceState ()

This method is deprecated.
will be removed in the next alpha

Returns
DeviceState the DeviceState when the Sidecar library is present and a DeviceState with POSTURE_UNKNOWN otherwise.

getWindowLayoutInfo

public abstract WindowLayoutInfo getWindowLayoutInfo (Context context)

This method is deprecated.
will be removed in the next alpha

Parameters
context Context

Returns
WindowLayoutInfo the WindowLayoutInfo when Sidecar library is present and an empty info otherwise

getWindowLayoutInfo

public abstract WindowLayoutInfo getWindowLayoutInfo (Activity activity)

This method is deprecated.
will be removed in the next alpha

Parameters
activity Activity

Returns
WindowLayoutInfo the WindowLayoutInfo when Sidecar library is present and an empty info otherwise

registerDeviceStateChangeCallback

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

Registers a callback for device state changes.

Parameters
executor Executor

callback Consumer

registerLayoutChangeCallback

public abstract void registerLayoutChangeCallback (Activity activity, 
                Executor executor, 
                Consumer<WindowLayoutInfo> callback)

Registers a callback for layout changes of the window for the supplied Activity. Must be called only after the it is attached to the window.

Parameters
activity Activity

executor Executor

callback Consumer

registerLayoutChangeCallback

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

This method is deprecated.
will be removed in the next alpha.

Registers a callback for layout changes of the window for Activity associated with the supplied Context. Must be called only after the it is attached to the window.

Parameters
context Context

executor Executor

callback Consumer

unregisterDeviceStateChangeCallback

public abstract void unregisterDeviceStateChangeCallback (Consumer<DeviceState> callback)

Unregisters a callback for device state changes.

Parameters
callback Consumer

unregisterLayoutChangeCallback

public abstract void unregisterLayoutChangeCallback (Consumer<WindowLayoutInfo> callback)

Unregisters a callback for window layout changes of the Activity window.

Parameters
callback Consumer