# androidx.window.embedding

*** ** * ** ***

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityEmbeddingController` | The controller that allows checking the current `https://developer.android.com/reference/android/app/Activity.html` embedding status. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityFilter` | Filter for `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityRule` and `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPlaceholderRule` that checks for component name match when a new activity is started. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityRule` | Layout configuration rules for individual activities with split layouts. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityRule.Builder` | Builder for `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityRule`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` | A container that holds a stack of activities, overlapping and bound to the same rectangle on the screen. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes` | The attributes of the divider layout and behavior. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.DragRange` | Describes the range that the user is allowed to drag the draggable divider. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.DragRange.SplitRatioDragRange` | A drag range represented as an interval of the primary container's split ratios. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.DraggableDividerAttributes` | The attributes of a draggable divider. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.DraggableDividerAttributes.Builder` | The `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.DraggableDividerAttributes` builder. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.FixedDividerAttributes` | The attributes of a fixed divider. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.FixedDividerAttributes.Builder` | The `https://developer.android.com/reference/kotlin/androidx/window/embedding/DividerAttributes.FixedDividerAttributes` builder. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddedActivityWindowInfo` | Describes the embedded window related info of an activity. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAnimationBackground` | Background to be used for window transition animations for embedding activities if the animation requires a background. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAnimationBackground.ColorBackground` | An {@link EmbeddingAnimationBackground} to specify of using a developer-defined color as the animation background. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAnimationParams` | Parameters to be used for window transition animations for embedding activities. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAnimationParams.AnimationSpec` | The animation to use when an activity transitions (e.g. open, close, or change). |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAnimationParams.Builder` | Builder for creating an instance of `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAnimationParams`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingAspectRatio` | The aspect ratio of the parent window bound to allow embedding with the rule. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration` | Configurations of Activity Embedding environment that defines how the embedded Activities behave. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.Builder` | Builder for creating an instance of `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingConfiguration.DimAreaBehavior` | The area of dimming to apply. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingRule` | Base abstract class for activity embedding presentation rules, such as `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPairRule` and `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityRule`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/RuleController` | The controller to manage `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingRule`s. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributes` | Attributes that describe how the parent window (typically the activity task window) is split between the primary and secondary activity containers, including: |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributes.Builder` | Builder for creating an instance of `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributes`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributes.LayoutDirection` | The layout direction of the primary and secondary activity containers. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributes.SplitType` | The type of parent window split, which defines the proportion of the parent window occupied by the primary and secondary activity containers. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributesCalculatorParams` | The parameter container used to report the current device and window state in `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitController#setSplitAttributesCalculator(kotlin.Function1)` and references the corresponding `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitRule` by `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitAttributesCalculatorParams#splitRuleTag()` if `https://developer.android.com/reference/kotlin/androidx/window/embedding/EmbeddingRule#tag()` is specified. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitController` | The controller class that gets information about the currently active activity splits and provides interaction points to customize the splits and form new splits. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitController.SplitSupportStatus` | A class to determine if activity splits with Activity Embedding are currently available. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitInfo` | Describes a split pair of two containers with activities. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPairFilter` | Filter for `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPairRule` and used to find if a pair of activities should be put in a split. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPairRule` | Split configuration rules for activity pairs. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPairRule.Builder` | Builder for `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPairRule`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPinRule` | Split configuration rules for pinning an `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPinRule.Builder` | Builder for `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPinRule`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPlaceholderRule` | Configuration rules for split placeholders. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPlaceholderRule.Builder` | Builder for `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitPlaceholderRule`. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitRule` | Split configuration rules for activities that are launched to side in a split. |
| `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitRule.FinishBehavior` | Determines what happens with the associated container when all activities are finished in one of the containers in a split. |

## Extension functions summary

|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html` | `@https://developer.android.com/reference/kotlin/androidx/window/RequiresWindowSdkExtension(version = 5) https://developer.android.com/reference/android/os/Bundle.html.https://developer.android.com/reference/kotlin/androidx/window/embedding/package-summary#(android.os.Bundle).setLaunchingActivityStack(android.content.Context,androidx.window.embedding.ActivityStack)( context: https://developer.android.com/reference/android/content/Context.html, activityStack: https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack )` Sets the target launching `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` to the given `https://developer.android.com/reference/android/os/Bundle.html`. |

## Extension functions

### Bundle.setLaunchingActivityStack

Artifact: [androidx.window:window](https://developer.android.com/jetpack/androidx/releases/window) [View Source](https://cs.android.com/search?q=file:androidx/window/embedding/ActivityEmbeddingOptions.kt+function:setLaunchingActivityStack) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/window#1.4.0)

```
@RequiresWindowSdkExtension(version = 5)
fun Bundle.setLaunchingActivityStack(
    context: Context,
    activityStack: ActivityStack
): Bundle
```

Sets the target launching `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` to the given `https://developer.android.com/reference/android/os/Bundle.html`.

The `https://developer.android.com/reference/android/os/Bundle.html` then could be used to launch an `https://developer.android.com/reference/android/app/Activity.html` to the top of the `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` through `https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent)`. If there's a bundle used for customizing how the `https://developer.android.com/reference/android/app/Activity.html` should be started by `https://developer.android.com/reference/android/app/ActivityOptions.html#toBundle()` or `https://developer.android.com/reference/kotlin/androidx/core/app/ActivityOptionsCompat#toBundle()`, it's suggested to use the bundle to call this method.

It is suggested to use a visible `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` reported by `https://developer.android.com/reference/kotlin/androidx/window/embedding/SplitController#splitInfoList(android.app.Activity)` or `https://developer.android.com/reference/kotlin/androidx/window/embedding/OverlayController#overlayInfo(kotlin.String)`, or the launching activity will be launched on the default target if the `https://developer.android.com/reference/kotlin/androidx/window/embedding/package-summary#(android.os.Bundle).setLaunchingActivityStack(android.content.Context,androidx.window.embedding.ActivityStack)` no longer exists in the host task. The default target could be the top of the visible split's secondary `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack`, or the top of the host task.

Below samples are use cases to specify the launching `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack`.

```kotlin
import androidx.core.app.ActivityOptionsCompat
import androidx.window.embedding.ActivityStack
import androidx.window.embedding.SplitController
import androidx.window.embedding.setLaunchingActivityStack

var primaryActivityStack: ActivityStack? = null

SplitController.getInstance(primaryActivity).splitInfoList(primaryActivity).collect {
    splitInfoList ->
    primaryActivityStack = splitInfoList.last().primaryActivityStack
}

primaryActivity.startActivity(
    INTENT,
    ActivityOptionsCompat.makeBasic()
        .toBundle()!!
        .setLaunchingActivityStack(primaryActivity, primaryActivityStack!!),
)
```

```kotlin
import androidx.core.app.ActivityOptionsCompat
import androidx.window.embedding.ActivityStack
import androidx.window.embedding.OverlayController
import androidx.window.embedding.setLaunchingActivityStack

var overlayActivityStack: ActivityStack? = null

OverlayController.getInstance(context).overlayInfo(TAG_OVERLAY).collect { overlayInfo ->
    overlayActivityStack = overlayInfo.activityStack
}

// The use case is to launch an Activity to an existing overlay ActivityStack from the overlain
// Activity. If activityStack is not specified, the activity is launched to the top of the
// host task behind the overlay ActivityStack.
overlainActivity.startActivity(
    INTENT,
    ActivityOptionsCompat.makeBasic()
        .toBundle()!!
        .setLaunchingActivityStack(overlainActivity, overlayActivityStack!!),
)
```

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | The `https://developer.android.com/reference/android/content/Context.html` that is going to be used for launching activity with this `https://developer.android.com/reference/android/os/Bundle.html`, which is usually be the `https://developer.android.com/reference/android/app/Activity.html` of the app that hosts the task. |
| `activityStack: https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` | The target `https://developer.android.com/reference/kotlin/androidx/window/embedding/ActivityStack` for launching. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/window/WindowSdkExtensions#extensionVersion()` is less than 5. |