BluetoothSocketSettings.Builder


public static final class BluetoothSocketSettings.Builder
extends Object

java.lang.Object
   ↳ android.bluetooth.BluetoothSocketSettings.Builder


Builder for BluetoothSocketSettings.

Summary

Public constructors

Builder()

Public methods

BluetoothSocketSettings build()

Builds a BluetoothSocketSettings object.

BluetoothSocketSettings.Builder setAuthenticationRequired(boolean authenticationRequired)

Sets the authentication requirement for the Bluetooth socket.

BluetoothSocketSettings.Builder setEncryptionRequired(boolean encryptionRequired)

Sets the encryption requirement for the Bluetooth socket.

BluetoothSocketSettings.Builder setL2capPsm(int l2capPsm)

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

BluetoothSocketSettings.Builder setRfcommServiceName(String rfcommServiceName)

Sets the RFCOMM service name associated with the Bluetooth socket.

BluetoothSocketSettings.Builder setRfcommUuid(UUID rfcommUuid)

Sets the RFCOMM service UUID associated with the Bluetooth socket.

BluetoothSocketSettings.Builder setSocketType(int socketType)

Sets the socket type.

Inherited methods

Public constructors

Builder

public Builder ()

Public methods

build

public BluetoothSocketSettings build ()

Builds a BluetoothSocketSettings object.

Returns
BluetoothSocketSettings A new BluetoothSocketSettings object with the configured parameters. This value cannot be null.

Throws
IllegalArgumentException on invalid parameters

setAuthenticationRequired

public BluetoothSocketSettings.Builder setAuthenticationRequired (boolean authenticationRequired)

Sets the authentication requirement for the Bluetooth socket.

Defaults to false.

Parameters
authenticationRequired boolean: true if authentication is required for this socket, false otherwise.

Returns
BluetoothSocketSettings.Builder This builder. This value cannot be null.

setEncryptionRequired

public BluetoothSocketSettings.Builder setEncryptionRequired (boolean encryptionRequired)

Sets the encryption requirement for the Bluetooth socket.

Defaults to false.

Parameters
encryptionRequired boolean: true if encryption is required for this socket, false otherwise.

Returns
BluetoothSocketSettings.Builder This builder. This value cannot be null.

setL2capPsm

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 sockets.

Valid PSM values for 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.

Parameters
l2capPsm int: The L2CAP PSM value. Value is between 128 and 255 inclusive

Returns
BluetoothSocketSettings.Builder This builder. This value cannot be null.

Throws
IllegalArgumentException If l2cap PSM is not in given range.

setRfcommServiceName

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 sockets.

Defaults to null.

Parameters
rfcommServiceName String: The RFCOMM service name. This value cannot be null.

Returns
BluetoothSocketSettings.Builder This builder.

setRfcommUuid

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 sockets.

Defaults to null.

Parameters
rfcommUuid UUID: The RFCOMM service UUID. This value cannot be null.

Returns
BluetoothSocketSettings.Builder This builder.

setSocketType

public BluetoothSocketSettings.Builder setSocketType (int socketType)

Sets the socket type.

Must be one of:

Defaults to BluetoothSocket#TYPE_RFCOMM.

Parameters
socketType int: The type of socket. Value is BluetoothSocket.TYPE_RFCOMM, BluetoothSocket.TYPE_SCO, BluetoothSocket.TYPE_L2CAP, or BluetoothSocket.TYPE_LE

Returns
BluetoothSocketSettings.Builder This builder. This value cannot be null.

Throws
IllegalArgumentException If socketType is invalid.