RemoteCallbackList.Builder


public static final class RemoteCallbackList.Builder
extends Object

java.lang.Object
   ↳ android.os.RemoteCallbackList.Builderandroid.os.IInterface>


Builder for RemoteCallbackList.

Summary

Nested classes

interface RemoteCallbackList.Builder.InterfaceDiedCallbackIInterface>

For notifying when the process hosting a callback interface has died. 

Public constructors

Builder(int frozenCalleePolicy)

Creates a Builder for RemoteCallbackList.

Public methods

RemoteCallbackList build()

Builds and returns a RemoteCallbackList.

RemoteCallbackList.Builder setExecutor(Executor executor)

Sets the executor to be used when invoking callbacks asynchronously.

RemoteCallbackList.Builder setInterfaceDiedCallback(InterfaceDiedCallback callback)

Sets the callback to be invoked when an interface dies.

RemoteCallbackList.Builder setMaxQueueSize(int maxQueueSize)

Sets the max queue size.

Inherited methods

Public constructors

Builder

Added in API level 36
public Builder (int frozenCalleePolicy)

Creates a Builder for RemoteCallbackList.

Parameters
frozenCalleePolicy int: When the callback recipient's process is frozen, this parameter specifies when/whether callbacks are invoked. It's important to choose a strategy that's right for the use case. Leaving the policy unset with RemoteCallbackList.FROZEN_CALLEE_POLICY_UNSET is not recommended as it allows callbacks to be invoked while the recipient is frozen. Value is RemoteCallbackList.FROZEN_CALLEE_POLICY_UNSET, RemoteCallbackList.FROZEN_CALLEE_POLICY_ENQUEUE_ALL, RemoteCallbackList.FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT, or RemoteCallbackList.FROZEN_CALLEE_POLICY_DROP

Public methods

build

Added in API level 36
public RemoteCallbackList build ()

Builds and returns a RemoteCallbackList.

Returns
RemoteCallbackList The built RemoteCallbackList object. This value cannot be null.

setExecutor

Added in API level 36
public RemoteCallbackList.Builder setExecutor (Executor executor)

Sets the executor to be used when invoking callbacks asynchronously. This is only used when callbacks need to be invoked asynchronously, e.g. when the process hosting a callback becomes unfrozen. Callbacks that can be invoked immediately run on the same thread that calls RemoteCallbackList.broadcast(Consumer) synchronously.

Parameters
executor Executor: This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
Returns
RemoteCallbackList.Builder This value cannot be null.

setInterfaceDiedCallback

Added in API level 36
public RemoteCallbackList.Builder setInterfaceDiedCallback (InterfaceDiedCallback callback)

Sets the callback to be invoked when an interface dies.

Parameters
callback InterfaceDiedCallback: This value cannot be null.
Returns
RemoteCallbackList.Builder This value cannot be null.

setMaxQueueSize

Added in API level 36
public RemoteCallbackList.Builder setMaxQueueSize (int maxQueueSize)

Sets the max queue size.

Parameters
maxQueueSize int: The max size limit on the queue that stores callbacks added when the recipient's process is frozen. Once the limit is reached, the oldest callback is dropped to keep the size under the limit. Should only be called for RemoteCallbackList.FROZEN_CALLEE_POLICY_ENQUEUE_ALL.
Returns
RemoteCallbackList.Builder This builder. This value cannot be null.
Throws
IllegalArgumentException if the maxQueueSize is not positive.
UnsupportedOperationException if frozenCalleePolicy is not RemoteCallbackList.FROZEN_CALLEE_POLICY_ENQUEUE_ALL.