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

# BluetoothGattConnectionSettings.Builder

*** ** * ** ***


`
public
static
final

class
BluetoothGattConnectionSettings.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#Builder()() ` Creates a new Builder for `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings`. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#build()() ` Builds a `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings` object. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setAutoConnectEnabled(boolean)(boolean autoConnectEnabled) ` Setting this to true will enable the automatic connection to remote device when It is available. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setAutomaticMtuEnabled(boolean)(boolean automaticMtuEnabled) ` Sets if the MTU (Maximum Transmission Unit) needs to be negotiated for given connection or not. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setOpportunisticEnabled(boolean)(boolean opportunisticEnabled) ` Sets whether this GATT client is opportunistic. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setPathlossThresholdDb(int)(int pathlossThresholdDb) ` Sets the Pathloss threshold for initiating a connection. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setRssiThresholdDbm(int)(int rssiThresholdDbm) ` Sets the RSSI threshold for initiating a connection. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setTransport(int)(int transport) ` Sets the transport for this Gatt settings. |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
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

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
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` `
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` `
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 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

Creates a new Builder for `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings`.

<br />

## Public methods

### build

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

```
public BluetoothGattConnectionSettings build ()
```

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

<br />

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

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | on invalid parameters |

### setAutoConnectEnabled

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

```
public BluetoothGattConnectionSettings.Builder setAutoConnectEnabled (boolean autoConnectEnabled)
```

Setting this to true will enable the automatic connection to remote device when It is
available. Setting it to False would trigger direct connect to remote device

<br />

| Parameters ||
|---|---|
| `autoConnectEnabled` | `boolean`: true if auto connection is enabled, false otherwise. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | This builder. This value cannot be `null`. <br /> |

### setAutomaticMtuEnabled

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

```
public BluetoothGattConnectionSettings.Builder setAutomaticMtuEnabled (boolean automaticMtuEnabled)
```

Sets if the MTU (Maximum Transmission Unit) needs to be negotiated for given connection
or not. This is set to true by default so that MTU exchange happens after the connection.
Applications have to set it to false to disable the automatic negotiation. Setting this
to false does not prevent MTU negotiation if a client explicitly requests it using `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestMtu(int)` or if it's triggered internally by other profiles.

<br />

| Parameters ||
|---|---|
| `automaticMtuEnabled` | `boolean`: true if Default MTU setting needs to be applied on this connection, false otherwise. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | This builder. This value cannot be `null`. <br /> |

### setOpportunisticEnabled

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

```
public BluetoothGattConnectionSettings.Builder setOpportunisticEnabled (boolean opportunisticEnabled)
```

Sets whether this GATT client is opportunistic. An opportunistic GATT client does not
hold a GATT connection. It automatically disconnects when no other GATT connections are
active for the remote device

<br />

| Parameters ||
|---|---|
| `opportunisticEnabled` | `boolean`: true if this connection is opportunistic, false otherwise. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | This builder. This value cannot be `null`. <br /> |

### setPathlossThresholdDb

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public BluetoothGattConnectionSettings.Builder setPathlossThresholdDb (int pathlossThresholdDb)
```

Sets the Pathloss threshold for initiating a connection. If the device is already
connected, then the GATT connection will succeed regardless of the Pathloss Threshold.

The Pathloss threshold is used to initiate an LE connection to a remote device when
autoConnect is enabled. When autoConnect is enabled, the Bluetooth controller will add
the remote device to the accept list and initiate the connection when the device is in
range and has minimal pathloss. The Bluetooth controller will initiate the connection if
the Pathloss is lower than the given Pathloss threshold value.

This is just a preference for the Bluetooth controller; the controller may or may not
use this pathloss threshold value to initiate the connection.

When multiple applications request connections with different pathloss threshold
values, the Bluetooth system will use the maximum of pathloss threshold among all active
requests when initiating the next LE connection based on pathloss threshold.

Default pathloss threshold will be set to `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings#PATHLOSS_THRESHOLD_NOT_SET` which
indicates that pathloss based LE connection trigger is not enabled.

When the Pathloss is not available, or this value is `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings#PATHLOSS_THRESHOLD_NOT_SET`, then system will fall back to the RSSI threshold based
connection trigger if RSSI threshold is set using `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setRssiThresholdDbm(int)`

<br />

| Parameters ||
|---|---|
| `pathlossThresholdDb` | `int`: the pathloss threshold in dB for initiating connection. Value is between -1 and 100 inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | This builder. This value cannot be `null`. <br /> |

### setRssiThresholdDbm

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public BluetoothGattConnectionSettings.Builder setRssiThresholdDbm (int rssiThresholdDbm)
```

Sets the RSSI threshold for initiating a connection. If the device is already connected,
then the GATT connection will succeed regardless of the RSSI.

The RSSI threshold is used to initiate an LE connection to a remote device when
autoConnect is enabled. When autoConnect is enabled, the Bluetooth controller will add
the remote device to the accept list and initiate the connection when the device is in
range and has a strong signal. The Bluetooth controller will initiate the connection if
the RSSI is greater than the given RSSI threshold value.

This is just a preference for the Bluetooth controller; the controller may or may not
use this threshold to initiate the connection.

When multiple applications request connections with different RSSI threshold values,
the Bluetooth system will use the lowest (least stringent) RSSI threshold among all
active requests when initiating the next LE connection based on signal strength, allowing
connections to be initiated at weaker signal levels if any app requests it.

Default RSSI threshold will be set to `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings#RSSI_THRESHOLD_NOT_SET` which indicates
that RSSI based LE connection trigger is not enabled.

Pathloss threshold set using `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder#setPathlossThresholdDb(int)` will be prioritized over
RSSI threshold for triggering LE connection. RSSI threshold will be used for triggering
LE connection only if pathloss threshold is not set.

<br />

| Parameters ||
|---|---|
| `rssiThresholdDbm` | `int`: the RSSI threshold in dBm for initiating connection. Value is between -128 and 20 inclusive <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | This builder. This value cannot be `null`. <br /> |

### setTransport

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

```
public BluetoothGattConnectionSettings.Builder setTransport (int transport)
```

Sets the transport for this Gatt settings. preferred transport for GATT connections to
remote dual-mode devices.

<br />

| Parameters ||
|---|---|
| `transport` | `int`: Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#TRANSPORT_AUTO` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#TRANSPORT_BREDR` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#TRANSPORT_LE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/bluetooth/BluetoothGattConnectionSettings.Builder` | This builder. This value cannot be `null`. <br /> |