# 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)

*** ** * ** ***


```
class WindowInfoTrackerCallbackAdapter : WindowInfoTracker
```

<br />

*** ** * ** ***

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

An adapter for `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker` that allows listening for `https://developer.android.com/reference/kotlin/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/kotlin/androidx/window/layout/WindowInfoTracker` directly.

## Summary

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

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[addWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#addWindowLayoutInfoListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer))( activity: https://developer.android.com/reference/android/app/Activity.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, consumer: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo> )` **This function is deprecated.** Use WindowInfoTracker.registerWindowLayoutInfoListener(Activity, Executor, Consumer). |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[addWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#addWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))( context: @https://developer.android.com/reference/kotlin/androidx/annotation/UiContext https://developer.android.com/reference/android/content/Context.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, consumer: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo> )` **This function is deprecated.** Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer). |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[registerWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))( context: @https://developer.android.com/reference/kotlin/androidx/annotation/UiContext https://developer.android.com/reference/android/content/Context.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo> )` **This function is deprecated.** Use WindowInfoTracker.registerWindowLayoutInfoListener(Context, Executor, Consumer). |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[removeWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#removeWindowLayoutInfoListener(androidx.core.util.Consumer))(consumer: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo>)` **This function is deprecated.** Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer). |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[unregisterWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer))( listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo> )` **This function is deprecated.** Use WindowInfoTracker.unregisterWindowLayoutInfoListener(Consumer). |

### Inherited functions

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

**This function is deprecated.** This adapter is no longer necessary.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[registerWindowEngagementInfoListener](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker#registerWindowEngagementInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer))(
context: @https://developer.android.com/reference/kotlin/androidx/annotation/UiContext https://developer.android.com/reference/android/content/Context.html,
executor: https://developer.android.com/reference/java/util/concurrent/Executor.html,
listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowEngagementInfo>
)`

**This function is deprecated.** This adapter is no longer necessary.
`open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[unregisterWindowEngagementInfoListener](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker#unregisterWindowEngagementInfoListener(androidx.core.util.Consumer))(
listener: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowEngagementInfo>
)`

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

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

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

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

### Inherited properties

From [androidx.window.layout.WindowInfoTracker](https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/window/layout/SupportedPosture>` `@https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension(version = 6)
https://developer.android.com/reference/kotlin/androidx/window/layout/WindowInfoTracker#supportedPostures()`

**This property 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)

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

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

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

## Public functions

### 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)

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

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

Registers a listener to consume `https://developer.android.com/reference/kotlin/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/kotlin/androidx/window/layout/WindowInfoTracker#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer)` instead.

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/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)

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

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

Registers a `https://developer.android.com/reference/kotlin/androidx/annotation/UiContext` listener to consume `https://developer.android.com/reference/kotlin/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/kotlin/androidx/window/layout/WindowInfoTracker#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer)` instead.

| Parameters |
|---|---|
| `context: @https://developer.android.com/reference/kotlin/androidx/annotation/UiContext https://developer.android.com/reference/android/content/Context.html` | a `https://developer.android.com/reference/kotlin/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`. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | that the consumer will invoke on. |
| `consumer: https://developer.android.com/reference/kotlin/androidx/core/util/Consumer<https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo>` | for `https://developer.android.com/reference/kotlin/androidx/window/layout/WindowLayoutInfo` values. |

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

### registerWindowLayoutInfoListener

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

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

Registers a `https://developer.android.com/reference/kotlin/androidx/annotation/UiContext` listener to consume `https://developer.android.com/reference/kotlin/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/kotlin/androidx/window/layout/WindowInfoTracker#registerWindowLayoutInfoListener(android.content.Context,java.util.concurrent.Executor,androidx.core.util.Consumer)` instead.

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/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)

```
fun [removeWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#removeWindowLayoutInfoListener(androidx.core.util.Consumer))(consumer: Consumer<WindowLayoutInfo>): Unit
```

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

Remove a listener to stop consuming `https://developer.android.com/reference/kotlin/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/kotlin/androidx/window/layout/WindowInfoTracker#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer)` instead.

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

### unregisterWindowLayoutInfoListener

```
open fun [unregisterWindowLayoutInfoListener](https://developer.android.com/reference/kotlin/androidx/window/java/layout/WindowInfoTrackerCallbackAdapter#unregisterWindowLayoutInfoListener(androidx.core.util.Consumer))(
    listener: Consumer<WindowLayoutInfo>
): Unit
```

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

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

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

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

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