# SplitControllerCallbackAdapter

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/embedding/SplitControllerCallbackAdapter.kt+class:androidx.window.java.embedding.SplitControllerCallbackAdapter) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/window#1.1.0)

*** ** * ** ***


```
@ExperimentalWindowApi
public final class SplitControllerCallbackAdapter
```

<br />

*** ** * ** ***

An adapted interface for `https://developer.android.com/reference/androidx/window/embedding/SplitController` that provides callback shaped APIs to report the latest split information with `https://developer.android.com/reference/androidx/window/embedding/SplitInfo` list.

It should only be used if `https://developer.android.com/reference/androidx/window/embedding/SplitController#splitInfoList(android.app.Activity)` is not available. For example, an app is written in Java and cannot use Flow APIs.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#SplitControllerCallbackAdapter(androidx.window.embedding.SplitController)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/SplitController controller)` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#addSplitListener(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/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/SplitInfo>> consumer )` Registers a listener for updates about the active split state(s) that this activity is part of. |
| `final void` | `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#removeSplitListener(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/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/SplitInfo>> consumer )` Unregisters a listener that was previously registered via `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#addSplitListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer)`. |

## Public constructors

### SplitControllerCallbackAdapter

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

```
public SplitControllerCallbackAdapter(@NonNull SplitController controller)
```

## Public methods

### addSplitListener

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

```
public final void addSplitListener(
    @NonNull Activity activity,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull List<@NonNull SplitInfo>> consumer
)
```

Registers a listener for updates about the active split state(s) that this activity is part of. An activity can be in zero, one or more active splits. More than one active split is possible if an activity created multiple containers to side, stacked on top of each other. Or it can be in two different splits at the same time - in a secondary container for one (it was launched to the side) and in the primary for another (it launched another activity to the side). The reported splits in the list are ordered from bottom to top by their z-order, more recent splits appearing later. Guaranteed to be called at least once to report the most recent state.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/Activity.html activity` | only split that this `https://developer.android.com/reference/android/app/Activity.html` is part of will be reported. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | when there is an update to the active split state(s), the `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#addSplitListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer)` will be invoked on this `https://developer.android.com/reference/java/util/concurrent/Executor.html`. |
| `@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/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/SplitInfo>> consumer` | `https://developer.android.com/reference/androidx/core/util/Consumer` that will be invoked on the `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#addSplitListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer)` when there is an update to the active split state(s). |

### removeSplitListener

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

```
public final void removeSplitListener(
    @NonNull Consumer<@NonNull List<@NonNull SplitInfo>> consumer
)
```

Unregisters a listener that was previously registered via `https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter#addSplitListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer)`.

| 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/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/window/embedding/SplitInfo>> consumer` | the previously registered `https://developer.android.com/reference/androidx/core/util/Consumer` to unregister. |