# SplitControllerCallbackAdapter

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

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/window/java/embedding/SplitControllerCallbackAdapter "View this page in Java")


```
@ExperimentalWindowApi
class SplitControllerCallbackAdapter
```

<br />

*** ** * ** ***

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

It should only be used if [SplitController.splitInfoList](https://developer.android.com/reference/kotlin/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                                                                                                                                                                |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SplitControllerCallbackAdapter](https://developer.android.com/reference/kotlin/androidx/window/java/embedding/SplitControllerCallbackAdapter#SplitControllerCallbackAdapter(androidx.window.embedding.SplitController))`(controller: `[SplitController](https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitController)`)` |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [addSplitListener](https://developer.android.com/reference/kotlin/androidx/window/java/embedding/SplitControllerCallbackAdapter#addSplitListener(android.app.Activity,java.util.concurrent.Executor,androidx.core.util.Consumer))`(` ` activity: `[Activity](https://developer.android.com/reference/android/app/Activity.html)`,` ` executor: `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor.html)`,` ` consumer: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[SplitInfo](https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitInfo)`>>` `)` Registers a listener for updates about the active split state(s) that this activity is part of. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [removeSplitListener](https://developer.android.com/reference/kotlin/androidx/window/java/embedding/SplitControllerCallbackAdapter#removeSplitListener(androidx.core.util.Consumer))`(consumer: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[SplitInfo](https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitInfo)`>>)` Unregisters a listener that was previously registered via [addSplitListener](https://developer.android.com/reference/kotlin/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)  

```
SplitControllerCallbackAdapter(controller: SplitController)
```  

## Public functions

### addSplitListener

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

```
fun addSplitListener(
    activity: Activity,
    executor: Executor,
    consumer: Consumer<List<SplitInfo>>
): Unit
```

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

```
fun removeSplitListener(consumer: Consumer<List<SplitInfo>>): Unit
```

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

|                                                                                                                                              Parameters                                                                                                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| `consumer: `[Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer)`<`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[SplitInfo](https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitInfo)`>>` | the previously registered [Consumer](https://developer.android.com/reference/kotlin/androidx/core/util/Consumer) to unregister. |