# BluetoothGattServer

Added in[API level 18](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#inhconstants)\|[Methods](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#inhmethods)  

# BluetoothGattServer

*** ** * ** ***

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

`
public

final

class
BluetoothGattServer
`  
`

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


``


implements

`[BluetoothProfile](https://developer.android.com/reference/android/bluetooth/BluetoothProfile)`


`

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

<br />

*** ** * ** ***

Public API for the Bluetooth GATT Profile server role.

This class provides Bluetooth GATT server role functionality, allowing applications to create Bluetooth Smart services and characteristics.

BluetoothGattServer is a proxy object for controlling the Bluetooth Service via IPC. Use[BluetoothManager.openGattServer](https://developer.android.com/reference/android/bluetooth/BluetoothManager#openGattServer(android.content.Context,%20android.bluetooth.BluetoothGattServerCallback))to get an instance of this class.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[android.bluetooth.BluetoothProfile](https://developer.android.com/reference/android/bluetooth/BluetoothProfile) |--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `int`                                                              | [A2DP](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#A2DP) Advanced Audio Distribution Profile (A2DP)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | `int`                                                              | [CSIP_SET_COORDINATOR](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#CSIP_SET_COORDINATOR) Coordinated Set Identification Profile (CSIP) set coordinator                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | | [String](https://developer.android.com/reference/java/lang/String) | [EXTRA_PREVIOUS_STATE](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PREVIOUS_STATE) Extra for the connection state intents of the individual profiles.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | [String](https://developer.android.com/reference/java/lang/String) | [EXTRA_PROFILE](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_PROFILE) Extra for the[BluetoothProfile](https://developer.android.com/reference/android/bluetooth/BluetoothProfile)that the intent applies to.                                                                                                                                                                                                                                                                                                                                                                                                                          | | [String](https://developer.android.com/reference/java/lang/String) | [EXTRA_STATE](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#EXTRA_STATE) Extra for the connection state intents of the individual profiles.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | `int`                                                              | [GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT) Generic Attribute Profile (GATT)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | `int`                                                              | [GATT_SERVER](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT_SERVER) Generic Attribute Profile (GATT) Server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | `int`                                                              | [HAP_CLIENT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HAP_CLIENT) <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | `int`                                                              | [HEADSET](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEADSET) Headset and Handsfree profile                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | | `int`                                                              | [HEALTH](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEALTH) *This constant was deprecated in API level 29. Health Device Profile (HDP) and MCAP protocol are no longer used. New apps should use Bluetooth Low Energy based solutions such as[BluetoothGatt](https://developer.android.com/reference/android/bluetooth/BluetoothGatt),[BluetoothAdapter.listenUsingL2capChannel()](https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#listenUsingL2capChannel()), or[BluetoothDevice.createL2capChannel(int)](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#createL2capChannel(int))* | | `int`                                                              | [HEARING_AID](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HEARING_AID) Hearing Aid Device                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | `int`                                                              | [HID_DEVICE](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#HID_DEVICE) Human Interface Device (HID) Device                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | `int`                                                              | [LE_AUDIO](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#LE_AUDIO) LE Audio Device                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | `int`                                                              | [SAP](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#SAP) SIM Access Profile (SAP)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | | `int`                                                              | [STATE_CONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED) The profile is in connected state                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | | `int`                                                              | [STATE_CONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING) The profile is in connecting state                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | `int`                                                              | [STATE_DISCONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED) The profile is in disconnected state                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | | `int`                                                              | [STATE_DISCONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING) The profile is in disconnecting state                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` boolean`                                                                                                                                                                    | ` `[addService](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#addService(android.bluetooth.BluetoothGattService))`(`[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)` service) ` Add a service to the list of services to be hosted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` void`                                                                                                                                                                       | ` `[cancelConnection](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#cancelConnection(android.bluetooth.BluetoothDevice))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device) ` Disconnects an established connection, or cancels a connection attempt currently in progress.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` void`                                                                                                                                                                       | ` `[clearServices](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#clearServices())`() ` Remove all services from the list of provided services.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` void`                                                                                                                                                                       | ` `[close](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#close())`() ` Close this GATT server instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` boolean`                                                                                                                                                                    | ` `[connect](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#connect(android.bluetooth.BluetoothDevice,%20boolean))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, boolean autoConnect) ` Initiate a connection to a Bluetooth GATT capable device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)`>`           | ` `[getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#getConnectedDevices())`() ` Not supported - please use[BluetoothManager.getConnectedDevices(int)](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int))with[BluetoothProfile.GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT)as argument                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` int`                                                                                                                                                                        | ` `[getConnectionState](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#getConnectionState(android.bluetooth.BluetoothDevice))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device) ` Not supported - please use[BluetoothManager.getConnectedDevices(int)](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int))with[BluetoothProfile.GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT)as argument                                                                                                                                                                                                                                                                                                                                                      |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)`>`           | ` `[getDevicesMatchingConnectionStates](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#getDevicesMatchingConnectionStates(int[]))`(int[] states) ` Not supported - please use[BluetoothManager.getDevicesMatchingConnectionStates(int, int[])](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getDevicesMatchingConnectionStates(int,%20int[]))with[BluetoothProfile.GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT)as first argument                                                                                                                                                                                                                                                                                                                                                                                       |
| ` `[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)                                                                     | ` `[getService](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#getService(java.util.UUID))`(`[UUID](https://developer.android.com/reference/java/util/UUID)` uuid) ` Returns a[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)from the list of services offered by this device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)`>` | ` `[getServices](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#getServices())`() ` Returns a list of GATT services offered by this device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` int`                                                                                                                                                                        | ` `[notifyCharacteristicChanged](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#notifyCharacteristicChanged(android.bluetooth.BluetoothDevice,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean,%20byte[]))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, `[BluetoothGattCharacteristic](https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic)` characteristic, boolean confirm, byte[] value) ` Send a notification or indication that a local characteristic has been updated.                                                                                                                                                                                                                                                                                                          |
| ` boolean`                                                                                                                                                                    | ` `[notifyCharacteristicChanged](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#notifyCharacteristicChanged(android.bluetooth.BluetoothDevice,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, `[BluetoothGattCharacteristic](https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic)` characteristic, boolean confirm) ` *This method was deprecated in API level 33. Use[BluetoothGattServer.notifyCharacteristicChanged(BluetoothDevice, BluetoothGattCharacteristic, boolean, byte[])](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#notifyCharacteristicChanged(android.bluetooth.BluetoothDevice,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean,%20byte[]))as this is not memory safe.* |
| ` void`                                                                                                                                                                       | ` `[readPhy](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#readPhy(android.bluetooth.BluetoothDevice))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device) ` Read the current transmitter PHY and receiver PHY of the connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` boolean`                                                                                                                                                                    | ` `[removeService](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#removeService(android.bluetooth.BluetoothGattService))`(`[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)` service) ` Removes a service from the list of services to be provided.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` boolean`                                                                                                                                                                    | ` `[sendResponse](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#sendResponse(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20byte[]))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, int requestId, int status, int offset, byte[] value) ` Send a response to a read or write request to a remote device.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                                                                                                                       | ` `[setPreferredPhy](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#setPreferredPhy(android.bluetooth.BluetoothDevice,%20int,%20int,%20int))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device, int txPhy, int rxPhy, int phyOptions) ` Set the preferred connection PHY for this app.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |

| ### 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*.                                                                                             | ||
| From interface` `[android.bluetooth.BluetoothProfile](https://developer.android.com/reference/android/bluetooth/BluetoothProfile)` ` |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[List](https://developer.android.com/reference/java/util/List)`<`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)`>` | ` `[getConnectedDevices](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#getConnectedDevices())`() ` Get connected devices for this specific profile.                                                                                                                                    | | ` abstract int`                                                                                                                                                              | ` `[getConnectionState](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#getConnectionState(android.bluetooth.BluetoothDevice))`(`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)` device) ` Get the current connection state of the profile | | ` abstract `[List](https://developer.android.com/reference/java/util/List)`<`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)`>` | ` `[getDevicesMatchingConnectionStates](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#getDevicesMatchingConnectionStates(int[]))`(int[] states) ` Get a list of devices that match any of the given connection states.                                                                 | ||

## Public methods

### addService

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

```
public boolean addService (BluetoothGattService service)
```

Add a service to the list of services to be hosted.

Once a service has been added to the list, the service and its included characteristics will be provided by the local device.

If the local device has already exposed services when this function is called, a service update notification will be sent to all clients.

The[BluetoothGattServerCallback.onServiceAdded](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onServiceAdded(int,%20android.bluetooth.BluetoothGattService))callback will indicate whether this service has been added successfully. Do not add another service before this callback.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                                                   Parameters                                                   ||
|-----------|-----------------------------------------------------------------------------------------------------|
| `service` | `BluetoothGattService`: Service to be added to the list of services provided by this device. <br /> |

|                                 Returns                                  ||
|-----------|---------------------------------------------------------------|
| `boolean` | true, if the request to add service has been initiated <br /> |

### cancelConnection

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

```
public void cancelConnection (BluetoothDevice device)
```

Disconnects an established connection, or cancels a connection attempt currently in progress.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                    Parameters                     ||
|----------|-----------------------------------------|
| `device` | `BluetoothDevice`: Remote device <br /> |

### clearServices

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

```
public void clearServices ()
```

Remove all services from the list of provided services.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

### close

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

```
public void close ()
```

Close this GATT server instance.

Application should call this method as early as possible after it is done with this GATT server.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

### connect

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

```
public boolean connect (BluetoothDevice device, 
                boolean autoConnect)
```

Initiate a connection to a Bluetooth GATT capable device.

The connection may not be established right away, but will be completed when the remote device is available. A[BluetoothGattServerCallback.onConnectionStateChange](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onConnectionStateChange(android.bluetooth.BluetoothDevice,%20int,%20int))callback will be invoked when the connection state changes as a result of this function.

The autoConnect parameter determines whether to actively connect to the remote device, or rather passively scan and finalize the connection when the remote device is in range/available. Generally, the first ever connection to a device should be direct (autoConnect set to false) and subsequent connections to known devices should be invoked with the autoConnect parameter set to true.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                                                                                  Parameters                                                                                  ||
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `device`      | `BluetoothDevice` <br />                                                                                                                                      |
| `autoConnect` | `boolean`: Whether to directly connect to the remote device (false) or to automatically connect as soon as the remote device becomes available (true). <br /> |

|                                   Returns                                    ||
|-----------|-------------------------------------------------------------------|
| `boolean` | true, if the connection attempt was initiated successfully <br /> |

### getConnectedDevices

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

```
public List<BluetoothDevice> getConnectedDevices ()
```

Not supported - please use[BluetoothManager.getConnectedDevices(int)](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int))with[BluetoothProfile.GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT)as argument

<br />

|                                                                                                          Returns                                                                                                           ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List)`<`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)`>` | List of devices. The list will be empty on error. <br /> |

|                                                             Throws                                                              ||
|------------------------------------------------------------------------------------------------------------------|---------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | on every call |

### getConnectionState

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

```
public int getConnectionState (BluetoothDevice device)
```

Not supported - please use[BluetoothManager.getConnectedDevices(int)](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getConnectedDevices(int))with[BluetoothProfile.GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT)as argument

<br />

|                          Parameters                          ||
|----------|----------------------------------------------------|
| `device` | `BluetoothDevice`: Remote bluetooth device. <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Returns                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | State of the profile connection. One of[STATE_CONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED),[STATE_CONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING),[STATE_DISCONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED),[STATE_DISCONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING)Value is[STATE_DISCONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED),[STATE_CONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING),[STATE_CONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED), or[STATE_DISCONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING) <br /> |

|                                                             Throws                                                              ||
|------------------------------------------------------------------------------------------------------------------|---------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | on every call |

### getDevicesMatchingConnectionStates

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

```
public List<BluetoothDevice> getDevicesMatchingConnectionStates (int[] states)
```

Not supported - please use[BluetoothManager.getDevicesMatchingConnectionStates(int,
int[])](https://developer.android.com/reference/android/bluetooth/BluetoothManager#getDevicesMatchingConnectionStates(int,%20int[]))with[BluetoothProfile.GATT](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#GATT)as first argument

<br />

|                                                                                                                                                                                                                                                                                                Parameters                                                                                                                                                                                                                                                                                                 ||
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `states` | `int`: Array of states. States can be one of[BluetoothProfile.STATE_CONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED),[BluetoothProfile.STATE_CONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTING),[BluetoothProfile.STATE_DISCONNECTED](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED),[BluetoothProfile.STATE_DISCONNECTING](https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTING), <br /> |

|                                                                                                          Returns                                                                                                           ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List)`<`[BluetoothDevice](https://developer.android.com/reference/android/bluetooth/BluetoothDevice)`>` | List of devices. The list will be empty on error. <br /> |

|                                                             Throws                                                              ||
|------------------------------------------------------------------------------------------------------------------|---------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | on every call |

### getService

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

```
public BluetoothGattService getService (UUID uuid)
```

Returns a[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)from the list of services offered by this device.

If multiple instances of the same service (as identified by UUID) exist, the first instance of the service is returned.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.

<br />

|                      Parameters                      ||
|--------|----------------------------------------------|
| `uuid` | `UUID`: UUID of the requested service <br /> |

|                                                                                                      Returns                                                                                                      ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| [BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService) | BluetoothGattService if supported, or null if the requested service is not offered by this device. <br /> |

### getServices

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

```
public List<BluetoothGattService> getServices ()
```

Returns a list of GATT services offered by this device.

An application must call[addService(BluetoothGattService)](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#addService(android.bluetooth.BluetoothGattService))to add a service to the list of services offered by this device.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.

<br />

|                                                                                                                            Returns                                                                                                                             ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List)`<`[BluetoothGattService](https://developer.android.com/reference/android/bluetooth/BluetoothGattService)`>` | List of services. Returns an empty list if no services have been added yet. <br /> |

### notifyCharacteristicChanged

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

```
public int notifyCharacteristicChanged (BluetoothDevice device, 
                BluetoothGattCharacteristic characteristic, 
                boolean confirm, 
                byte[] value)
```

Send a notification or indication that a local characteristic has been updated.

A notification or indication is sent to the remote device to signal that the characteristic has been updated. This function should be invoked for every client that requests notifications/indications by writing to the "Client Configuration" descriptor for the given characteristic.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                                                             Parameters                                                             ||
|------------------|------------------------------------------------------------------------------------------------------------------|
| `device`         | `BluetoothDevice`: the remote device to receive the notification/indication This value cannot be`null`. <br />   |
| `characteristic` | `BluetoothGattCharacteristic`: the local characteristic that has been updated This value cannot be`null`. <br /> |
| `confirm`        | `boolean`:`true`to request confirmation from the client (indication) or`false`to send a notification <br />      |
| `value`          | `byte`: the characteristic value This value cannot be`null`. <br />                                              |

|                                                                                                                                                                                                                                                                                                                                                                                      Returns                                                                                                                                                                                                                                                                                                                                                                                       ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | whether the notification has been triggered successfully Value is[BluetoothStatusCodes.SUCCESS](https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#SUCCESS),[BluetoothStatusCodes.ERROR_MISSING_BLUETOOTH_CONNECT_PERMISSION](https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_MISSING_BLUETOOTH_CONNECT_PERMISSION), android.bluetooth.BluetoothStatusCodes.ERROR_DEVICE_NOT_CONNECTED,[BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND](https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_PROFILE_SERVICE_NOT_BOUND), or[BluetoothStatusCodes.ERROR_UNKNOWN](https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN) <br /> |

|                                                                         Throws                                                                         ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the characteristic value or service is null |

### notifyCharacteristicChanged

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

```
public boolean notifyCharacteristicChanged (BluetoothDevice device, 
                BluetoothGattCharacteristic characteristic, 
                boolean confirm)
```

<br />

**This method was deprecated in API level 33.**   
Use[BluetoothGattServer.notifyCharacteristicChanged(BluetoothDevice,
BluetoothGattCharacteristic, boolean, byte[])](https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#notifyCharacteristicChanged(android.bluetooth.BluetoothDevice,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean,%20byte[]))as this is not memory safe.

Send a notification or indication that a local characteristic has been updated.

A notification or indication is sent to the remote device to signal that the characteristic has been updated. This function should be invoked for every client that requests notifications/indications by writing to the "Client Configuration" descriptor for the given characteristic.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                                                         Parameters                                                          ||
|------------------|-----------------------------------------------------------------------------------------------------------|
| `device`         | `BluetoothDevice`: The remote device to receive the notification/indication <br />                        |
| `characteristic` | `BluetoothGattCharacteristic`: The local characteristic that has been updated <br />                      |
| `confirm`        | `boolean`: true to request confirmation from the client (indication), false to send a notification <br /> |

|                                   Returns                                   ||
|-----------|------------------------------------------------------------------|
| `boolean` | true, if the notification has been triggered successfully <br /> |

|                                                                         Throws                                                                         ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the characteristic value or service is null |

### readPhy

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

```
public void readPhy (BluetoothDevice device)
```

Read the current transmitter PHY and receiver PHY of the connection. The values are returned in[BluetoothGattServerCallback.onPhyRead](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onPhyRead(android.bluetooth.BluetoothDevice,%20int,%20int,%20int))  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                                   Parameters                                   ||
|----------|----------------------------------------------------------------------|
| `device` | `BluetoothDevice`: The remote device to send this response to <br /> |

### removeService

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

```
public boolean removeService (BluetoothGattService service)
```

Removes a service from the list of services to be provided.  
For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                            Parameters                            ||
|-----------|-------------------------------------------------------|
| `service` | `BluetoothGattService`: Service to be removed. <br /> |

|                         Returns                         ||
|-----------|----------------------------------------------|
| `boolean` | true, if the service has been removed <br /> |

### sendResponse

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

```
public boolean sendResponse (BluetoothDevice device, 
                int requestId, 
                int status, 
                int offset, 
                byte[] value)
```

Send a response to a read or write request to a remote device.

This function must be invoked in when a remote read/write request is received by one of these callback methods:

- [BluetoothGattServerCallback.onCharacteristicReadRequest](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onCharacteristicReadRequest(android.bluetooth.BluetoothDevice,%20int,%20int,%20android.bluetooth.BluetoothGattCharacteristic))
- [BluetoothGattServerCallback.onCharacteristicWriteRequest](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onCharacteristicWriteRequest(android.bluetooth.BluetoothDevice,%20int,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean,%20boolean,%20int,%20byte[]))
- [BluetoothGattServerCallback.onDescriptorReadRequest](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onDescriptorReadRequest(android.bluetooth.BluetoothDevice,%20int,%20int,%20android.bluetooth.BluetoothGattDescriptor))
- [BluetoothGattServerCallback.onDescriptorWriteRequest](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onDescriptorWriteRequest(android.bluetooth.BluetoothDevice,%20int,%20android.bluetooth.BluetoothGattDescriptor,%20boolean,%20boolean,%20int,%20byte[]))

<br />

For apps targeting[Build.VERSION_CODES.R](https://developer.android.com/reference/android/os/Build.VERSION_CODES#R)or lower, this requires the[Manifest.permission.BLUETOOTH](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH)permission which can be gained with a simple`<uses-permission>`manifest tag.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

<br />

|                                       Parameters                                        ||
|-------------|----------------------------------------------------------------------------|
| `device`    | `BluetoothDevice`: The remote device to send this response to <br />       |
| `requestId` | `int`: The ID of the request that was received with the callback <br />    |
| `status`    | `int`: The status of the request to be sent to the remote devices <br />   |
| `offset`    | `int`: Value offset for partial read/write response <br />                 |
| `value`     | `byte`: The value of the attribute that was read/written (optional) <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### setPreferredPhy

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

```
public void setPreferredPhy (BluetoothDevice device, 
                int txPhy, 
                int rxPhy, 
                int phyOptions)
```

Set the preferred connection PHY for this app. Please note that this is just a recommendation, whether the PHY change will happen depends on other applications preferences, local and remote controller capabilities. Controller can override these settings.

[BluetoothGattServerCallback.onPhyUpdate](https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onPhyUpdate(android.bluetooth.BluetoothDevice,%20int,%20int,%20int))will be triggered as a result of this call, even if no PHY change happens. It is also triggered when remote device updates the PHY.  
For apps targeting[Build.VERSION_CODES.S](https://developer.android.com/reference/android/os/Build.VERSION_CODES#S)or or higher, this requires the[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)permission which can be gained with[Activity.requestPermissions(String[], int)](https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)).  
Requires[Manifest.permission.BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT)

<br />

|                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `device`     | `BluetoothDevice`: The remote device to send this response to <br />                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `txPhy`      | `int`: preferred transmitter PHY. Bitwise OR of any of[BluetoothDevice.PHY_LE_1M_MASK](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_1M_MASK),[BluetoothDevice.PHY_LE_2M_MASK](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_2M_MASK), and[BluetoothDevice.PHY_LE_CODED_MASK](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_CODED_MASK). <br />                                  |
| `rxPhy`      | `int`: preferred receiver PHY. Bitwise OR of any of[BluetoothDevice.PHY_LE_1M_MASK](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_1M_MASK),[BluetoothDevice.PHY_LE_2M_MASK](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_2M_MASK), and[BluetoothDevice.PHY_LE_CODED_MASK](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_CODED_MASK). <br />                                     |
| `phyOptions` | `int`: preferred coding to use when transmitting on the LE Coded PHY. Can be one of[BluetoothDevice.PHY_OPTION_NO_PREFERRED](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_OPTION_NO_PREFERRED),[BluetoothDevice.PHY_OPTION_S2](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_OPTION_S2)or[BluetoothDevice.PHY_OPTION_S8](https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_OPTION_S8) <br /> |