SplitController

@ExperimentalWindowApi public final class SplitController


Controller class that will be used to get information about the currently active activity splits, as well as provide interaction points to customize them and form new splits. A split is a pair of containers that host activities in the same or different tasks, combined under the same parent window of the hosting task.

A pair of activities can be put into split by providing a static or runtime split rule and launching activity in the same task and process using [android.content.Context.startActivity].

This class should be configured before [android.app.Application.onCreate] for upcoming activity launches using the split rules statically defined in an XML using [androidx.startup.Initializer] and [Companion.initialize]. See Jetpack App Startup reference for more information.

Summary

Public methods

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

Registers a listener for updates about the active split state(s) that this activity is part of.

final void

Unregisters all runtime rules added with registerRule.

final @NonNull Set<@NonNull EmbeddingRule>

Returns a copy of the currently applied split configurations.

final boolean

Indicates whether the split functionality is supported on the device.

final void

Registers a new runtime rule.

final void

Unregisters a listener for updates about the active split states.

final void

Unregisters a runtime rule that was previously registered via SplitController.registerRule.

Public methods

addSplitListener

public final void addSplitListener(
    Activity activity,
    Executor executor,
    Consumer<List<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.

clearRegisteredRules

public final void clearRegisteredRules()

Unregisters all runtime rules added with registerRule.

getSplitRules

public final @NonNull Set<@NonNull EmbeddingRulegetSplitRules()

Returns a copy of the currently applied split configurations.

isSplitSupported

public final boolean isSplitSupported()

Indicates whether the split functionality is supported on the device. Note that the device might enable splits in all conditions, but it should be available in some state