AbstractSandboxedUiAdapter


public abstract class AbstractSandboxedUiAdapter implements SandboxedUiAdapter, SessionObserverFactoryRegistry


An abstract class that implements SandboxedUiAdapter while abstracting away methods that do not need to be implemented by a UI provider.

UI providers should use this class rather than implementing SandboxedUiAdapter directly.

Summary

Nested types

An abstract class that implements SandboxedUiAdapter.Session so that a UI provider does not need to implement the entire interface.

Public constructors

Public methods

final void
addObserverFactory(
    @NonNull SessionObserverFactory sessionObserverFactory
)

Adds a SessionObserverFactory for tracking UI presentation state across UI sessions.

final @NonNull List<@NonNull SessionObserverFactory>
final void
removeObserverFactory(
    @NonNull SessionObserverFactory sessionObserverFactory
)

Removes a SessionObserverFactory, if it has been previously added with addObserverFactory.

Inherited methods

From androidx.privacysandbox.ui.core.SandboxedUiAdapter
abstract void
openSession(
    @NonNull Context context,
    @NonNull SessionConstants sessionConstants,
    int initialWidth,
    int initialHeight,
    boolean isZOrderOnTop,
    @NonNull Executor clientExecutor,
    @NonNull SandboxedUiAdapter.SessionClient client
)

Open a new session for displaying content with an initial size of initialWidthxinitialHeight pixels.

Public constructors

AbstractSandboxedUiAdapter

Added in 1.0.0-alpha13
public AbstractSandboxedUiAdapter()

Public methods

addObserverFactory

public final void addObserverFactory(
    @NonNull SessionObserverFactory sessionObserverFactory
)

Adds a SessionObserverFactory for tracking UI presentation state across UI sessions. This has no effect on already open sessions.

For each session that is created for the adapter after this call returns, SessionObserverFactory.create will be invoked to allow a new SessionObserver instance to be attached to the UI session. This SessionObserver will receive UI updates for the lifetime of the session. A separate SessionObserverFactory.create call will be made for each UI session.

getSessionObserverFactories

public final @NonNull List<@NonNull SessionObserverFactorygetSessionObserverFactories()

removeObserverFactory

public final void removeObserverFactory(
    @NonNull SessionObserverFactory sessionObserverFactory
)

Removes a SessionObserverFactory, if it has been previously added with addObserverFactory.

If the SessionObserverFactory was not previously added, no action is performed. Any existing SessionObserver instances that have been created by the SessionObserverFactory will continue to receive updates until their corresponding UI session has been closed. For any subsequent sessions created], no call to SessionObserverFactory.create will be made.