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

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder "View this page in Java")

```
class Builder
```

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

Builder for `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings`.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#Builder()()` <br /> |

| Public methods ||
|---|---|
| [BluetoothSocketSettings](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#build()()` Builds a `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings` object. |
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#setAuthenticationRequired(kotlin.Boolean)(authenticationRequired: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets the authentication requirement for the Bluetooth socket. |
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#setEncryptionRequired(kotlin.Boolean)(encryptionRequired: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets the encryption requirement for the Bluetooth socket. |
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#setL2capPsm(kotlin.Int)(l2capPsm: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the L2CAP PSM (Protocol/Service Multiplexer) for the Bluetooth socket. |
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#setRfcommServiceName(kotlin.String)(rfcommServiceName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Sets the RFCOMM service name associated with the Bluetooth socket. |
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#setRfcommUuid(java.util.UUID)(rfcommUuid: https://developer.android.com/reference/kotlin/java/util/UUID.html#)` Sets the RFCOMM service UUID associated with the Bluetooth socket. |
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#) | `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#setSocketType(kotlin.Int)(socketType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the socket type. |

## Public constructors

### Builder

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

```
Builder()
```

## Public methods

### build

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

```
fun build(): BluetoothSocketSettings
```

Builds a `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings` object.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings` | A new `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings` object with the configured parameters. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | on invalid parameters |

### setAuthenticationRequired

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

```
fun setAuthenticationRequired(authenticationRequired: Boolean): BluetoothSocketSettings.Builder
```

Sets the authentication requirement for the Bluetooth socket.

Defaults to `false`.

| Parameters ||
|---|---|
| `authenticationRequired` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if authentication is required for this socket, `false` otherwise. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#` | This builder. This value cannot be `null`. |

### setEncryptionRequired

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

```
fun setEncryptionRequired(encryptionRequired: Boolean): BluetoothSocketSettings.Builder
```

Sets the encryption requirement for the Bluetooth socket.

Defaults to `false`.

| Parameters ||
|---|---|
| `encryptionRequired` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` if encryption is required for this socket, `false` otherwise. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#` | This builder. This value cannot be `null`. |

### setL2capPsm

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

```
fun setL2capPsm(l2capPsm: Int): BluetoothSocketSettings.Builder
```

Sets the L2CAP PSM (Protocol/Service Multiplexer) for the Bluetooth socket.

This is only used for `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_LE:kotlin.Int` sockets.

Valid PSM values for `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_LE:kotlin.Int` sockets is ranging from 128 (0x80) to 255 (0xFF).

Application using this API is responsible for obtaining protocol/service multiplexer (PSM) value from remote device.

| Parameters ||
|---|---|
| `l2capPsm` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The L2CAP PSM value. Value is between 128 and 255 inclusive |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#` | This builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If l2cap PSM is not in given range. |

### setRfcommServiceName

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

```
fun setRfcommServiceName(rfcommServiceName: String): BluetoothSocketSettings.Builder
```

Sets the RFCOMM service name associated with the Bluetooth socket.

This name is used to identify the service when a remote device searches for it using SDP.

This is only used for `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_RFCOMM:kotlin.Int` sockets.

Defaults to `null`.

| Parameters ||
|---|---|
| `rfcommServiceName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The RFCOMM service name. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#` | This builder. |

### setRfcommUuid

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

```
fun setRfcommUuid(rfcommUuid: UUID): BluetoothSocketSettings.Builder
```

Sets the RFCOMM service UUID associated with the Bluetooth socket.

This UUID is used to uniquely identify the service when a remote device searches for it using SDP.

This is only used for `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_RFCOMM:kotlin.Int` sockets.

Defaults to `null`.

| Parameters ||
|---|---|
| `rfcommUuid` | [UUID](https://developer.android.com/reference/kotlin/java/util/UUID.html#): The RFCOMM service UUID. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#` | This builder. |

### setSocketType

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

```
fun setSocketType(socketType: Int): BluetoothSocketSettings.Builder
```

Sets the socket type.

Must be one of:

- `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_RFCOMM:kotlin.Int`
- `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_LE:kotlin.Int`

Defaults to `BluetoothSocket#TYPE_RFCOMM`.

| Parameters ||
|---|---|
| `socketType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The type of socket. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_RFCOMM:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_SCO:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_L2CAP:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocket#TYPE_LE:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/bluetooth/BluetoothSocketSettings.Builder#` | This builder. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If `socketType` is invalid. |