Builder


class Builder<E : IInterface!>
kotlin.Any
   ↳ android.os.RemoteCallbackList.Builder

Builder for RemoteCallbackList.

Summary

Nested classes
abstract

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

Public constructors
Builder(frozenCalleePolicy: Int)

Creates a Builder for RemoteCallbackList.

Public methods
RemoteCallbackList<E>

Builds and returns a RemoteCallbackList.

RemoteCallbackList.Builder<IInterface!>
setExecutor(executor: Executor)

Sets the executor to be used when invoking callbacks asynchronously.

RemoteCallbackList.Builder<IInterface!>

Sets the callback to be invoked when an interface dies.

RemoteCallbackList.Builder<IInterface!>
setMaxQueueSize(maxQueueSize: Int)

Sets the max queue size.

Public constructors

Builder

Builder(frozenCalleePolicy: Int)

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 FROZEN_CALLEE_POLICY_UNSET is not recommended as it allows callbacks to be invoked while the recipient is frozen. Value is android.os.RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET, android.os.RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_ALL, android.os.RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT, or android.os.RemoteCallbackList#FROZEN_CALLEE_POLICY_DROP

Public methods

build

fun build(): RemoteCallbackList<E>

Builds and returns a RemoteCallbackList.

Return
RemoteCallbackList<E> The built RemoteCallbackList object. This value cannot be null.

setExecutor

fun setExecutor(executor: Executor): RemoteCallbackList.Builder<IInterface!>

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 broadcast 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.
Return
RemoteCallbackList.Builder<IInterface!> This value cannot be null.

setInterfaceDiedCallback

fun setInterfaceDiedCallback(callback: RemoteCallbackList.Builder.InterfaceDiedCallback<E>): RemoteCallbackList.Builder<IInterface!>

Sets the callback to be invoked when an interface dies.

Parameters
callback RemoteCallbackList.Builder.InterfaceDiedCallback<E>: This value cannot be null.
Return
RemoteCallbackList.Builder<IInterface!> This value cannot be null.

setMaxQueueSize

fun setMaxQueueSize(maxQueueSize: Int): RemoteCallbackList.Builder<IInterface!>

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 FROZEN_CALLEE_POLICY_ENQUEUE_ALL.
Return
RemoteCallbackList.Builder<IInterface!> This builder. This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if the maxQueueSize is not positive.
java.lang.UnsupportedOperationException if frozenCalleePolicy is not FROZEN_CALLEE_POLICY_ENQUEUE_ALL.