# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Nested Classes | Methods | Inherited Methods

# WindowManager

`public interface WindowManager`
`implements ViewManager`

android.view.WindowManager

The interface that apps use to talk to the window manager.

Each window manager instance is bound to a particular `Display`. To obtain a `WindowManager` for a different display, use `Context#createDisplayContext` to obtain a `Context` for that display, then use `Context.getSystemService(Context.WINDOW_SERVICE)` to get the WindowManager.

The simplest way to show a window on another display is to create a `Presentation`. The presentation will automatically obtain a `WindowManager` and `Context` for that display.

## Summary

### Nested classes
`class` | `WindowManager.BadTokenException` Exception that is thrown when trying to add view whose `LayoutParams` `LayoutParams#token` is invalid.
`class` | `WindowManager.InvalidDisplayException` Exception that is thrown when calling `ViewManager.addView(View, ViewGroup.LayoutParams)` to a secondary display that cannot be found.
`class` | `WindowManager.LayoutParams`

### Public methods
`default void` | `addCrossWindowBlurEnabledListener(Consumer<Boolean> listener)` Adds a listener, which will be called when cross-window blurs are enabled/disabled at runtime.
`default void` | `addCrossWindowBlurEnabledListener(Executor executor, Consumer<Boolean> listener)` Adds a listener, which will be called when cross-window blurs are enabled/disabled at runtime.
`default WindowMetrics` | `getCurrentWindowMetrics()` Returns the `WindowMetrics` according to the current system state.
`abstract Display` | `getDefaultDisplay()` This method is deprecated. Use `Context#getDisplay()` instead.
`default WindowMetrics` | `getMaximumWindowMetrics()` Returns the largest `WindowMetrics` an app may expect in the current system state.
`default boolean` | `isCrossWindowBlurEnabled()` Returns whether cross-window blur is currently enabled.
`default void` | `removeCrossWindowBlurEnabledListener(Consumer<Boolean> listener)` Removes a listener, previously added with `addCrossWindowBlurEnabledListener(Executor, Consumer)`
`abstract void` | `removeViewImmediate(View view)` Special variation of `ViewManager.removeView(View)` that immediately invokes the given view hierarchy's `View.onDetachedFromWindow()` methods before returning.

### Inherited methods
From interface `android.view.ViewManager`
`abstract void` | `addView(View view, ViewGroup.LayoutParams params)` Assign the passed LayoutParams to the passed View and add the view to the window.
`abstract void` | `removeView(View view)`
`abstract void` | `updateViewLayout(View view, ViewGroup.LayoutParams params)`

## Public methods

### addCrossWindowBlurEnabledListener

    public void addCrossWindowBlurEnabledListener (Consumer<Boolean> listener)

Adds a listener, which will be called when cross-window blurs are enabled/disabled at runtime. This affects both window blur behind (see `LayoutParams#setBlurBehindRadius`) and window background blur (see `Window#setBackgroundBlurRadius`).

Cross-window blur might not be supported by some devices due to GPU limitations. It can also be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or when minimal post processing is requested. In such situations, no blur will be computed or drawn, so the blur target area will not be blurred. To handle this, the app might want to change its theme to one that does not use blurs.

The listener will be called on the main thread.

If the listener is added successfully, it will be called immediately with the current cross-window blur enabled state.

Parameters
`listener` | `Consumer`: the listener to be added. It will be called back with a boolean parameter, which is true if cross-window blur is enabled and false if it is disabled This value cannot be `null`.

See also:

- `removeCrossWindowBlurEnabledListener(Consumer)`
- `isCrossWindowBlurEnabled()`
- `WindowManager.LayoutParams.setBlurBehindRadius(int)`
- `Window.setBackgroundBlurRadius(int)`

### addCrossWindowBlurEnabledListener

    public void addCrossWindowBlurEnabledListener (Executor executor,
                    Consumer<Boolean> listener)

Adds a listener, which will be called when cross-window blurs are enabled/disabled at runtime. This affects both window blur behind (see `LayoutParams#setBlurBehindRadius`) and window background blur (see `Window#setBackgroundBlurRadius`).

Cross-window blur might not be supported by some devices due to GPU limitations. It can also be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or when minimal post processing is requested. In such situations, no blur will be computed or drawn, so the blur target area will not be blurred. To handle this, the app might want to change its theme to one that does not use blurs.

If the listener is added successfully, it will be called immediately with the current cross-window blur enabled state.

Parameters
`executor` | `Executor`: `Executor` to handle the listener callback This value cannot be `null`. Callback and listener events are dispatched through this `Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `Context.getMainExecutor()`. To dispatch events through a shared thread pool, you can use `AsyncTask#THREAD_POOL_EXECUTOR`.
`listener` | `Consumer`: the listener to be added. It will be called back with a boolean parameter, which is true if cross-window blur is enabled and false if it is disabled This value cannot be `null`.

See also:

- `removeCrossWindowBlurEnabledListener(Consumer)`
- `isCrossWindowBlurEnabled()`
- `WindowManager.LayoutParams.setBlurBehindRadius(int)`
- `Window.setBackgroundBlurRadius(int)`

### getCurrentWindowMetrics

    public WindowMetrics getCurrentWindowMetrics ()

Returns the `WindowMetrics` according to the current system state.

The metrics describe the size of the area the window would occupy with `MATCH_PARENT` width and height, and the `WindowInsets` such a window would have.

The value of this is based on the current windowing state of the system. For example, for activities in multi-window mode, the metrics returned are based on the current bounds that the user has selected for the `Activity`'s task.

In most scenarios, `getCurrentWindowMetrics()` rather than `getMaximumWindowMetrics()` is the correct API to use, since it ensures values reflect window size when the app is not fullscreen.

Returns
`WindowMetrics` | This value cannot be `null`.

See also:

- `getMaximumWindowMetrics()`
- `WindowMetrics`

### getDefaultDisplay

    public abstract Display getDefaultDisplay ()

This method is deprecated.
Use `Context#getDisplay()` instead.

Returns the `Display` upon which this `WindowManager` instance will create new windows.

Despite the name of this method, the display that is returned is not necessarily the primary display of the system (see `Display#DEFAULT_DISPLAY`). The returned display could instead be a secondary display that this window manager instance is managing. Think of it as the display that this `WindowManager` instance uses by default.

To create windows on a different display, you need to obtain a `WindowManager` for that `Display`. (See the `WindowManager` class documentation for more information.)

Returns
`Display` | The display that this window manager is managing.

### getMaximumWindowMetrics

    public WindowMetrics getMaximumWindowMetrics ()

Returns the largest `WindowMetrics` an app may expect in the current system state.

The value of this is based on the largest potential windowing state of the system. For example, for activities in multi-window mode, the metrics returned are based on the what the bounds would be if the user expanded the `Activity`'s task to cover the entire screen.

The metrics describe the size of the largest potential area the window might occupy with `MATCH_PARENT` width and height, and the `WindowInsets` such a window would have.

Note that this might still be smaller than the size of the physical display if certain areas of the display are not available to windows created in this `Context`. For example, given that there's a device which have a multi-task mode to limit activities to a half screen. In this case, `getMaximumWindowMetrics()` reports the bounds of the half screen which the activity is located.

Generally `getCurrentWindowMetrics()` is the correct API to use for choosing UI layouts. `getMaximumWindowMetrics()` are only appropriate when the application needs to know the largest possible size it can occupy if the user expands/maximizes it on the screen.

Returns
`WindowMetrics` | This value cannot be `null`.

See also:

- `getCurrentWindowMetrics()`
- `WindowMetrics`
- `Display.getRealSize(Point)`

### isCrossWindowBlurEnabled

    public boolean isCrossWindowBlurEnabled ()

Returns whether cross-window blur is currently enabled. This affects both window blur behind (see `LayoutParams#setBlurBehindRadius`) and window background blur (see `Window#setBackgroundBlurRadius`).

Cross-window blur might not be supported by some devices due to GPU limitations. It can also be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or when minimal post processing is requested. In such situations, no blur will be computed or drawn, so the blur target area will not be blurred. To handle this, the app might want to change its theme to one that does not use blurs. To listen for cross-window blur enabled/disabled events, use `addCrossWindowBlurEnabledListener(Executor, Consumer)`.

Returns
`boolean` |

See also:

- `addCrossWindowBlurEnabledListener(Executor, Consumer)`
- `WindowManager.LayoutParams.setBlurBehindRadius(int)`
- `Window.setBackgroundBlurRadius(int)`

### removeCrossWindowBlurEnabledListener

    public void removeCrossWindowBlurEnabledListener (Consumer<Boolean> listener)

Removes a listener, previously added with `addCrossWindowBlurEnabledListener(Executor, Consumer)`

Parameters
`listener` | `Consumer`: the listener to be removed This value cannot be `null`.

See also:

- `addCrossWindowBlurEnabledListener(Executor, Consumer)`

### removeViewImmediate

    public abstract void removeViewImmediate (View view)

Special variation of `ViewManager.removeView(View)` that immediately invokes the given view hierarchy's `View.onDetachedFromWindow()` methods before returning. This is not for normal applications; using it correctly requires great care.

Parameters
`view` | `View`: The view to be removed.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*