ActivityEmbeddingControllerCallbackAdapter


class ActivityEmbeddingControllerCallbackAdapter


An adapted interface for ActivityEmbeddingController that provides callback shaped APIs to report the latest EmbeddedActivityWindowInfo.

It should only be used if ActivityEmbeddingController.embeddedActivityWindowInfo is not available. For example, an app is written in Java and cannot use Flow APIs.

Summary

Public constructors

creates a callback adapter of ActivityEmbeddingController.embeddedActivityWindowInfo flow API.

Public functions

Unit
@RequiresWindowSdkExtension(version = 6)
addEmbeddedActivityWindowInfoListener(
    activity: Activity,
    executor: Executor,
    listener: Consumer<EmbeddedActivityWindowInfo>
)

Registers a listener for updates of EmbeddedActivityWindowInfo of activity.

Unit

Unregisters a listener that was previously registered via addEmbeddedActivityWindowInfoListener.

Public constructors

ActivityEmbeddingControllerCallbackAdapter

Added in 1.4.0-alpha05
ActivityEmbeddingControllerCallbackAdapter(
    controller: ActivityEmbeddingController
)

creates a callback adapter of ActivityEmbeddingController.embeddedActivityWindowInfo flow API.

Public functions

addEmbeddedActivityWindowInfoListener

Added in 1.4.0-alpha05
@RequiresWindowSdkExtension(version = 6)
fun addEmbeddedActivityWindowInfoListener(
    activity: Activity,
    executor: Executor,
    listener: Consumer<EmbeddedActivityWindowInfo>
): Unit

Registers a listener for updates of EmbeddedActivityWindowInfo of activity.

The listener will immediately be invoked with the latest value upon registration if the activity is currently embedded as EmbeddedActivityWindowInfo.isEmbedded is true.

When the activity is embedded, the listener will be invoked when EmbeddedActivityWindowInfo is changed. When the activity is not embedded, the listener will not be triggered unless the activity is becoming non-embedded from embedded.

Note that this API is only supported on the device with WindowSdkExtensions.extensionVersion equal to or larger than 6. If WindowSdkExtensions.extensionVersion is less than 6, this listener will not be invoked.

Parameters
activity: Activity

the Activity that is interested in getting the embedded window info.

executor: Executor

the Executor to dispatch the EmbeddedActivityWindowInfo change.

listener: Consumer<EmbeddedActivityWindowInfo>

the Consumer that will be invoked on the executor when there is an update to EmbeddedActivityWindowInfo.

removeEmbeddedActivityWindowInfoListener

Added in 1.4.0-alpha05
@RequiresWindowSdkExtension(version = 6)
fun removeEmbeddedActivityWindowInfoListener(
    listener: Consumer<EmbeddedActivityWindowInfo>
): Unit

Unregisters a listener that was previously registered via addEmbeddedActivityWindowInfoListener.

It's no-op if the listener has not been registered.

Parameters
listener: Consumer<EmbeddedActivityWindowInfo>

the previously registered Consumer to unregister.