WindowManager
public
final
class
WindowManager
extends Object
| java.lang.Object | |
| ↳ | 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 | |
|---|---|
WindowManager(Context context, WindowBackend windowBackend)
Get an instance of the class initialized with and connected to the provided |
|
Public methods | |
|---|---|
DeviceState
|
getDeviceState()
Get the current device state. |
WindowLayoutInfo
|
getWindowLayoutInfo()
Get current window layout information for the associated |
void
|
registerDeviceStateChangeCallback(Executor executor, Consumer<DeviceState> callback)
Register a callback for device state changes. |
void
|
registerLayoutChangeCallback(Executor executor, Consumer<WindowLayoutInfo> callback)
Register a callback for layout changes of the window of the current visual |
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 window. |
Inherited methods | |
|---|---|
Public constructors
WindowManager
public WindowManager (Context context, 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
public DeviceState getDeviceState ()
Get the current device state.
| Returns | |
|---|---|
DeviceState |
|
See also:
getWindowLayoutInfo
public WindowLayoutInfo getWindowLayoutInfo ()
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.
| 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 (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 | |
|---|---|
executor |
Executor |
callback |
Consumer |
See also:
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 window.
| Parameters | |
|---|---|
callback |
Consumer |