# BluetoothSocketSettings.Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder#inhmethods)  

# BluetoothSocketSettings.Builder

*** ** * ** ***

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

`
public
static
final

class
BluetoothSocketSettings.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|---------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.bluetooth.BluetoothSocketSettings.Builder |

<br />

*** ** * ** ***

Builder for[BluetoothSocketSettings](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings).

## Summary

|                                                  ### Public constructors                                                  ||
|------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder#Builder())`() ` |

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

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

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

```
public Builder ()
```

<br />

<br />

## Public methods

### build

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

```
public BluetoothSocketSettings build ()
```

Builds a[BluetoothSocketSettings](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings)object.

<br />

|                                                                                                                                                 Returns                                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [BluetoothSocketSettings](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings) | A new[BluetoothSocketSettings](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings)object with the configured parameters. This value cannot be`null`. <br /> |

|                                                            Throws                                                             ||
|--------------------------------------------------------------------------------------------------------|-----------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | on invalid parameters |

### setAuthenticationRequired

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

```
public BluetoothSocketSettings.Builder setAuthenticationRequired (boolean authenticationRequired)
```

Sets the authentication requirement for the Bluetooth socket.

Defaults to`false`.

<br />

|                                                    Parameters                                                    ||
|--------------------------|----------------------------------------------------------------------------------------|
| `authenticationRequired` | `boolean`:`true`if authentication is required for this socket,`false`otherwise. <br /> |

|                                                                                    Returns                                                                                     ||
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder) | This builder. This value cannot be`null`. <br /> |

### setEncryptionRequired

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

```
public BluetoothSocketSettings.Builder setEncryptionRequired (boolean encryptionRequired)
```

Sets the encryption requirement for the Bluetooth socket.

Defaults to`false`.

<br />

|                                                Parameters                                                ||
|----------------------|------------------------------------------------------------------------------------|
| `encryptionRequired` | `boolean`:`true`if encryption is required for this socket,`false`otherwise. <br /> |

|                                                                                    Returns                                                                                     ||
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder) | This builder. This value cannot be`null`. <br /> |

### setL2capPsm

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

```
public BluetoothSocketSettings.Builder setL2capPsm (int l2capPsm)
```

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

This is only used for[BluetoothSocket.TYPE_LE](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_LE)sockets.

Valid PSM values for[BluetoothSocket.TYPE_LE](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_LE)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.

<br />

|                                      Parameters                                       ||
|------------|---------------------------------------------------------------------------|
| `l2capPsm` | `int`: The L2CAP PSM value. Value is between 128 and 255 inclusive <br /> |

|                                                                                    Returns                                                                                     ||
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder) | This builder. This value cannot be`null`. <br /> |

|                                                                   Throws                                                                    ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/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#ApiLevels)  

```
public BluetoothSocketSettings.Builder setRfcommServiceName (String rfcommServiceName)
```

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[BluetoothSocket.TYPE_RFCOMM](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_RFCOMM)sockets.

Defaults to`null`.

<br />

|                                         Parameters                                         ||
|---------------------|-----------------------------------------------------------------------|
| `rfcommServiceName` | `String`: The RFCOMM service name. This value cannot be`null`. <br /> |

|                                                                      Returns                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------|----------------------|
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder) | This builder. <br /> |

### setRfcommUuid

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

```
public BluetoothSocketSettings.Builder setRfcommUuid (UUID rfcommUuid)
```

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[BluetoothSocket.TYPE_RFCOMM](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_RFCOMM)sockets.

Defaults to`null`.

<br />

|                                    Parameters                                     ||
|--------------|---------------------------------------------------------------------|
| `rfcommUuid` | `UUID`: The RFCOMM service UUID. This value cannot be`null`. <br /> |

|                                                                      Returns                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------|----------------------|
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder) | This builder. <br /> |

### setSocketType

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

```
public BluetoothSocketSettings.Builder setSocketType (int socketType)
```

Sets the socket type.

Must be one of:

- [BluetoothSocket.TYPE_RFCOMM](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_RFCOMM)
- [BluetoothSocket.TYPE_LE](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_LE)

Defaults to`BluetoothSocket#TYPE_RFCOMM`.

<br />

|                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                           ||
|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `socketType` | `int`: The type of socket. Value is[BluetoothSocket.TYPE_RFCOMM](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_RFCOMM),[BluetoothSocket.TYPE_SCO](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_SCO),[BluetoothSocket.TYPE_L2CAP](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_L2CAP), or[BluetoothSocket.TYPE_LE](https://developer.android.com/reference/android/bluetooth/BluetoothSocket#TYPE_LE) <br /> |

|                                                                                    Returns                                                                                     ||
|------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [BluetoothSocketSettings.Builder](https://developer.android.com/reference/android/bluetooth/BluetoothSocketSettings.Builder) | This builder. This value cannot be`null`. <br /> |

|                                                              Throws                                                               ||
|--------------------------------------------------------------------------------------------------------|---------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | If`socketType`is invalid. |