Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

```
class Builder<E : IInterface!>
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.os.RemoteCallbackList.Builder](https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#) |

Builder for `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList`.

## Summary

| Nested classes ||
|---|---|
| abstract | `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder.InterfaceDiedCallback` For notifying when the process hosting a callback interface has died. |

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#Builder(kotlin.Int)(frozenCalleePolicy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Creates a Builder for `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList`. |

| Public methods ||
|---|---|
| [RemoteCallbackList](https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList)\<E\> | `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#build()()` Builds and returns a `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList`. |
| [RemoteCallbackList.Builder](https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#)\<[IInterface](https://developer.android.com/reference/kotlin/android/os/IInterface)!\> | `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#setExecutor(java.util.concurrent.Executor)(executor: https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#)` Sets the executor to be used when invoking callbacks asynchronously. |
| [RemoteCallbackList.Builder](https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#)\<[IInterface](https://developer.android.com/reference/kotlin/android/os/IInterface)!\> | `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#setInterfaceDiedCallback(android.os.RemoteCallbackList.Builder.InterfaceDiedCallback)(callback: https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder.InterfaceDiedCallback<E>)` Sets the callback to be invoked when an interface dies. |
| [RemoteCallbackList.Builder](https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#)\<[IInterface](https://developer.android.com/reference/kotlin/android/os/IInterface)!\> | `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#setMaxQueueSize(kotlin.Int)(maxQueueSize: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the max queue size. |

## Public constructors

### Builder

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
Builder(frozenCalleePolicy: Int)
```

Creates a Builder for `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList`.

**Note:** If the kernel does not support frozen notifications, the list will silently fall back to `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET:kotlin.Int` behavior (i.e., callbacks are invoked immediately regardless of the frozen state of the target process). However, `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#getFrozenCalleePolicy()` will still return the policy specified here.

| Parameters ||
|---|---|
| `frozenCalleePolicy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): 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 `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET:kotlin.Int` is not recommended as it allows callbacks to be invoked while the recipient is frozen. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_UNSET:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_ALL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_MOST_RECENT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_DROP:kotlin.Int` |

## Public methods

### build

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun build(): RemoteCallbackList<E>
```

Builds and returns a `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList`.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList<E>` | The built `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList` object. This value cannot be `null`. |

### setExecutor

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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 `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#broadcast(java.util.function.Consumer)` synchronously.

| Parameters ||
|---|---|
| `executor` | [Executor](https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#): This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/kotlin/android/content/Context.html#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/kotlin/java/util/concurrent/Executor.html#` that dispatches to an appropriate thread. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#<https://developer.android.com/reference/kotlin/android/os/IInterface!>` | This value cannot be `null`. |

### setInterfaceDiedCallback

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
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](https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder.InterfaceDiedCallback)\<E\>: This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#<https://developer.android.com/reference/kotlin/android/os/IInterface!>` | This value cannot be `null`. |

### setMaxQueueSize

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

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

Sets the max queue size.

| Parameters ||
|---|---|
| `maxQueueSize` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): 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 `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_ALL:kotlin.Int`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList.Builder#<https://developer.android.com/reference/kotlin/android/os/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 `https://developer.android.com/reference/kotlin/android/os/RemoteCallbackList#FROZEN_CALLEE_POLICY_ENQUEUE_ALL:kotlin.Int`. |