SessionObserver


public interface SessionObserver


An interface that can be used by the client of a androidx.privacysandbox.ui.core.SandboxedUiAdapter.Session to receive updates about its state. One session may be associated with multiple session observers.

When a new UI session is started, onSessionOpened will be invoked for all registered observers. This callback will contain a SessionObserverContext object containing data which will be constant for the lifetime of the UI session. onUiContainerChanged will also be sent when a new session is opened. This callback will contain a Bundle representing the UI presentation of the session's view.

During the entire lifetime of the UI session, onUiContainerChanged will be sent when the UI presentation has changed. These updates will be throttled.

When the UI session has completed, onSessionClosed will be sent. After this point, no more callbacks will be sent and it is safe to free any resources associated with this session observer.

Summary

Public methods

abstract void

Called exactly once per session when the androidx.privacysandbox.ui.core.SandboxedUiAdapter.Session associated with this session observer closes.

abstract void

Called exactly once per session, when the androidx.privacysandbox.ui.core.SandboxedUiAdapter.Session associated with the session observer is created.

abstract void

Called when the UI container has changed its presentation state.

Public methods

onSessionClosed

Added in 1.0.0-alpha10
abstract void onSessionClosed()

Called exactly once per session when the androidx.privacysandbox.ui.core.SandboxedUiAdapter.Session associated with this session observer closes. No more callbacks will be made on this observer after this point, and any resources associated with it can be freed.

onSessionOpened

Added in 1.0.0-alpha10
abstract void onSessionOpened(@NonNull SessionObserverContext sessionObserverContext)

Called exactly once per session, when the androidx.privacysandbox.ui.core.SandboxedUiAdapter.Session associated with the session observer is created. sessionObserverContext contains data which will be constant for the lifetime of the UI session. The resources associated with the sessionObserverContext will be released when onSessionClosed is called.

onUiContainerChanged

Added in 1.0.0-alpha10
abstract void onUiContainerChanged(@NonNull Bundle uiContainerInfo)

Called when the UI container has changed its presentation state. Note that these updates will not be sent instantaneously, and will be throttled. This should not be used to react to UI changes on the client side as it is not sent in real time.