androidx.window.embedding


Classes

ActivityEmbeddingController

The controller that allows checking the current Activity embedding status.

ActivityFilter

Filter for ActivityRule and SplitPlaceholderRule that checks for component name match when a new activity is started.

ActivityRule

Layout configuration rules for individual activities with split layouts.

ActivityRule.Builder

Builder for ActivityRule.

ActivityStack

A container that holds a stack of activities, overlapping and bound to the same rectangle on the screen.

DividerAttributes

The attributes of the divider layout and behavior.

DividerAttributes.DragRange

Describes the range that the user is allowed to drag the draggable divider.

DividerAttributes.DragRange.SplitRatioDragRange

A drag range represented as an interval of the primary container's split ratios.

DividerAttributes.DraggableDividerAttributes

The attributes of a draggable divider.

DividerAttributes.DraggableDividerAttributes.Builder

The DraggableDividerAttributes builder.

DividerAttributes.FixedDividerAttributes

The attributes of a fixed divider.

DividerAttributes.FixedDividerAttributes.Builder

The FixedDividerAttributes builder.

EmbeddedActivityWindowInfo

Describes the embedded window related info of an activity.

EmbeddingAnimationBackground

Background to be used for window transition animations for embedding activities if the animation requires a background.

EmbeddingAnimationBackground.ColorBackground

An {@link EmbeddingAnimationBackground} to specify of using a developer-defined color as the animation background.

EmbeddingAspectRatio

The aspect ratio of the parent window bound to allow embedding with the rule.

EmbeddingConfiguration

Configurations of Activity Embedding environment that defines how the embedded Activities behave.

EmbeddingConfiguration.Builder

Builder for creating an instance of EmbeddingConfiguration.

EmbeddingConfiguration.DimAreaBehavior

The area of dimming to apply.

EmbeddingRule

Base abstract class for activity embedding presentation rules, such as SplitPairRule and ActivityRule.

RuleController

The controller to manage EmbeddingRules.

SplitAttributes

Attributes that describe how the parent window (typically the activity task window) is split between the primary and secondary activity containers, including:

SplitAttributes.Builder

Builder for creating an instance of SplitAttributes.

SplitAttributes.LayoutDirection

The layout direction of the primary and secondary activity containers.

SplitAttributes.SplitType

The type of parent window split, which defines the proportion of the parent window occupied by the primary and secondary activity containers.

SplitAttributesCalculatorParams

The parameter container used to report the current device and window state in SplitController.setSplitAttributesCalculator and references the corresponding SplitRule by splitRuleTag if SplitPairRule.tag is specified.

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.

SplitController.SplitSupportStatus

A class to determine if activity splits with Activity Embedding are currently available.

SplitInfo

Describes a split pair of two containers with activities.

SplitPairFilter

Filter for SplitPairRule and used to find if a pair of activities should be put in a split.

SplitPairRule

Split configuration rules for activity pairs.

SplitPairRule.Builder

Builder for SplitPairRule.

SplitPinRule

Split configuration rules for pinning an ActivityStack.

SplitPinRule.Builder

Builder for SplitPinRule.

SplitPlaceholderRule

Configuration rules for split placeholders.

SplitPlaceholderRule.Builder

Builder for SplitPlaceholderRule.

SplitRule

Split configuration rules for activities that are launched to side in a split.

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

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

Sets the target launching ActivityStack to the given Bundle.

Extension functions

setLaunchingActivityStack

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

Sets the target launching ActivityStack to the given Bundle.

The Bundle then could be used to launch an Activity to the top of the ActivityStack through Activity.startActivity. If there's a bundle used for customizing how the Activity should be started by ActivityOptions.toBundle or androidx.core.app.ActivityOptionsCompat.toBundle, it's suggested to use the bundle to call this method.

It is suggested to use a visible ActivityStack reported by SplitController.splitInfoList or OverlayController.overlayInfo, or the launching activity will be launched on the default target if the activityStack no longer exists in the host task. The default target could be the top of the visible split's secondary ActivityStack, or the top of the host task.

Below samples are use cases to specify the launching ActivityStack.

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!!)
)
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: Context

The android.content.Context that is going to be used for launching activity with this Bundle, which is usually be the android.app.Activity of the app that hosts the task.

activityStack: ActivityStack

The target ActivityStack for launching.