# WindowInfoTrackerCallbackAdapter

Artifact: [androidx.window:window-java](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/java/layout/WindowInfoTrackerCallbackAdapter.kt+class:androidx.window.java.layout.WindowInfoTrackerCallbackAdapter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/window#1.0.0) Deprecated in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

*** ** * ** ***


```
public final class WindowInfoTrackerCallbackAdapter implements WindowInfoTracker
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> This adapter is no longer necessary. Use WindowInfoTracker directly, use this instead:
>
> ```java
> WindowInfoTracker
> ```

An adapter for `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker` that allows listening for `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` updates using callbacks instead of `Flow`.

This adapter is no longer necessary the callback-based listeners have been added to WindowLayoutInfo. Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker` directly.

## Summary

| ### Public constructors |
|---|
| `[WindowInfoTrackerCallbackAdapter](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#WindowInfoTrackerCallbackAdapter(androidx.window.layout.WindowInfoTracker))(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker tracker)` **This method is deprecated.** This constructor is no longer necessary. |

| ### Public methods |
|---|---|
| `final void` | `[addWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#addWindowLayoutInfoListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/Activity.html activity, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> consumer )` **This method is deprecated.** Use WindowInfoTracker.registerWindowLayoutInfoListener(Activity, Executor, Consumer). |
| `final void` | `[addWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#addWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))( @https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> consumer )` **This method is deprecated.** Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer). |
| `void` | `[registerWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))( @https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> listener )` **This method is deprecated.** Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer). |
| `final void` | `[removeWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#removeWindowLayoutInfoListener(androidx.core.util.Consumer))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> consumer )` **This method is deprecated.** Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer). |
| `void` | `[unregisterWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> listener )` **This method is deprecated.** Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer). |

### Inherited methods

From [androidx.window.layout.WindowInfoTracker](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker) `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` `@https://developer.android.com/reference/androidx/window/RequiresWindowSdkExtension(version = 9)
[getCurrentWindowLayoutInfo](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#getCurrentWindowLayoutInfo(android.content.Context))(@https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)`

**This method is deprecated.** This adapter is no longer necessary.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/SupportedPosture>` `@https://developer.android.com/reference/androidx/window/RequiresWindowSdkExtension(version = 6)
[getSupportedPostures](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#getSupportedPostures())()`

**This method is deprecated.** This adapter is no longer necessary.
`void` `[registerWindowEngagementInfoListener](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#registerWindowEngagementInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))(
@https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowEngagementInfo> listener
)`

**This method is deprecated.** This adapter is no longer necessary.
`void` `[unregisterWindowEngagementInfoListener](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#unregisterWindowEngagementInfoListener(androidx.core.util.Consumer))(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowEngagementInfo> listener
)`

**This method is deprecated.** This adapter is no longer necessary.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowEngagementInfo>` `[windowEngagementInfo](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowEngagementInfo(android.content.Context))(@https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)`

**This method is deprecated.** This adapter is no longer necessary.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo>` `[windowLayoutInfo](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.app.Activity))(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.** This adapter is no longer necessary.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo>` `[windowLayoutInfo](https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context))(@https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)`

**This method is deprecated.** This adapter is no longer necessary.

## Public constructors

### WindowInfoTrackerCallbackAdapter

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/window#1.0.0) Deprecated in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

```
public [WindowInfoTrackerCallbackAdapter](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#WindowInfoTrackerCallbackAdapter(androidx.window.layout.WindowInfoTracker))(@NonNull WindowInfoTracker tracker)
```

> [!CAUTION]
> **This method is deprecated.**   
> This constructor is no longer necessary. Use WindowInfoTracker directly, use this instead:
>
> ```java
> tracker
> ```

Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker` constructor instead.

## Public methods

### addWindowLayoutInfoListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/window#1.0.0) Deprecated in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

```
public final void [addWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#addWindowLayoutInfoListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer))(
    @NonNull Activity activity,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use WindowInfoTracker.registerWindowLayoutInfoListener(Activity, Executor, Consumer), use this instead:
>
> ```java
> tracker.registerWindowLayoutInfoListener(activity, executor, listener)
> ```

Registers a listener to consume `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values of the `https://developer.android.com/reference/android/app/Activity.html` window from a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. If the same consumer is registered twice then this method is a no-op.

Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer)` instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/Activity.html activity` | an `https://developer.android.com/reference/android/app/Activity.html` that hosts a `https://developer.android.com/reference/android/view/Window.html`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | that the consumer will invoke on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> consumer` | for `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)` |   |

### addWindowLayoutInfoListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/window#1.1.0) Deprecated in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

```
public final void [addWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#addWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))(
    @UiContext @NonNull Context context,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer), use this instead:
>
> ```java
> tracker.registerWindowLayoutInfoListener(context, executor, listener)
> ```

Registers a `https://developer.android.com/reference/androidx/annotation/UiContext` listener to consume `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values from a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. If the same consumer is registered twice then this method is a no-op.

Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer)` instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | a `https://developer.android.com/reference/androidx/annotation/UiContext` such as an `https://developer.android.com/reference/android/app/Activity.html`, created with Context#createWindowContext or is a `https://developer.android.com/reference/android/inputmethodservice/InputMethodService.html`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | that the consumer will invoke on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> consumer` | for `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)` |   |

### registerWindowLayoutInfoListener

```
public void [registerWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))(
    @UiContext @NonNull Context context,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull WindowLayoutInfo> listener
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer).

Registers a `https://developer.android.com/reference/androidx/annotation/UiContext` listener to consume `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values. If the same listener is registered twice then this method is a no-op. Overridden here for compatibility.

Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer)` instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/UiContext @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | a `https://developer.android.com/reference/androidx/annotation/UiContext` such as an `https://developer.android.com/reference/android/app/Activity.html`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | that the listener will invoke on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> listener` | for `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)` |   |

### removeWindowLayoutInfoListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/window#1.0.0) Deprecated in [1.6.0-alpha05](https://developer.android.com/jetpack/androidx/releases/window#1.6.0-alpha05)

```
public final void [removeWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#removeWindowLayoutInfoListener(androidx.core.util.Consumer))(
    @NonNull Consumer<@NonNull WindowLayoutInfo> consumer
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer), use this instead:
>
> ```java
> tracker.unregisterWindowLayoutInfoListener(listener)
> ```

Remove a listener to stop consuming `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values from a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html`. If the listener has already been removed then this is a no-op.

Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer)` instead.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)` |   |

### unregisterWindowLayoutInfoListener

```
public void [unregisterWindowLayoutInfoListener](https://developer.android.com/reference/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer))(
    @NonNull Consumer<@NonNull WindowLayoutInfo> listener
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer).

Unregisters a listener to stop consuming `https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo` values. Overridden here for compatibility.

Use `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer)` instead.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/util/Consumer<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/layout/WindowLayoutInfo> listener` | The listener to be removed. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/window/layout/WindowInfoTracker#windowLayoutInfo(android.content.Context)` |   |