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

# BluetoothGattServerCallback

*** ** * ** ***


`
public


abstract
class
BluetoothGattServerCallback
`


`

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


`

`


`

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

<br />

*** ** * ** ***

This abstract class is used to implement `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer` callbacks.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#BluetoothGattServerCallback()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onCharacteristicReadRequest(android.bluetooth.BluetoothDevice,%20int,%20int,%20android.bluetooth.BluetoothGattCharacteristic)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int requestId, int offset, https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic characteristic) ` A remote client has requested to read a local characteristic. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onCharacteristicWriteRequest(android.bluetooth.BluetoothDevice,%20int,%20android.bluetooth.BluetoothGattCharacteristic,%20boolean,%20boolean,%20int,%20byte[])(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int requestId, https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) ` A remote client has requested to write to a local characteristic. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onConnectionStateChange(android.bluetooth.BluetoothDevice,%20int,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int status, int newState) ` Callback indicating when a remote device has been connected or disconnected. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onConnectionUpdated(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int interval, int latency, int supervisionTimeout, int status) ` Callback indicating the connection parameters were updated. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onDescriptorReadRequest(android.bluetooth.BluetoothDevice,%20int,%20int,%20android.bluetooth.BluetoothGattDescriptor)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int requestId, int offset, https://developer.android.com/reference/android/bluetooth/BluetoothGattDescriptor descriptor) ` A remote client has requested to read a local descriptor. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onDescriptorWriteRequest(android.bluetooth.BluetoothDevice,%20int,%20android.bluetooth.BluetoothGattDescriptor,%20boolean,%20boolean,%20int,%20byte[])(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int requestId, https://developer.android.com/reference/android/bluetooth/BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) ` A remote client has requested to write to a local descriptor. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onExecuteWrite(android.bluetooth.BluetoothDevice,%20int,%20boolean)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int requestId, boolean execute) ` Execute all pending write operations for this device. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onMtuChanged(android.bluetooth.BluetoothDevice,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int mtu) ` Callback indicating the MTU for a given device connection has changed. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onNotificationSent(android.bluetooth.BluetoothDevice,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int status) ` Callback invoked when a notification or indication has been sent to a remote device. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onPhyRead(android.bluetooth.BluetoothDevice,%20int,%20int,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int txPhy, int rxPhy, int status) ` Callback triggered as result of `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#readPhy(android.bluetooth.BluetoothDevice)` |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onPhyUpdate(android.bluetooth.BluetoothDevice,%20int,%20int,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int txPhy, int rxPhy, int status) ` Callback triggered as result of `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#setPreferredPhy(android.bluetooth.BluetoothDevice,%20int,%20int,%20int)`, or as a result of remote device changing the PHY. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onServiceAdded(int,%20android.bluetooth.BluetoothGattService)(int status, https://developer.android.com/reference/android/bluetooth/BluetoothGattService service) ` Indicates whether a local service has been added successfully. |
| ` void` | ` https://developer.android.com/reference/android/bluetooth/BluetoothGattServerCallback#onSubrateChange(android.bluetooth.BluetoothDevice,%20int,%20int)(https://developer.android.com/reference/android/bluetooth/BluetoothDevice device, int subrateMode, int status) ` Callback indicating LE connection's subrate parameters have changed. |

### Inherited methods

From class `

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

` `


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

Creates and returns a copy of this object.


`


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

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


`


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

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

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

Returns the runtime class of this `Object`.


`


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

Returns a hash code value for the object.


`


final

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

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


`


final

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

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


`


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

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

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

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

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

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Public constructors

### BluetoothGattServerCallback

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

```
public BluetoothGattServerCallback ()
```

<br />

<br />

## Public methods

### onCharacteristicReadRequest

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

```
public void onCharacteristicReadRequest (BluetoothDevice device, 
                int requestId, 
                int offset, 
                BluetoothGattCharacteristic characteristic)
```

A remote client has requested to read a local characteristic.

An application must call `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#sendResponse(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20byte[])` to complete the request.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that has requested the read operation <br /> |
| `requestId` | `int`: The Id of the request <br /> |
| `offset` | `int`: Offset into the value of the characteristic <br /> |
| `characteristic` | `BluetoothGattCharacteristic`: Characteristic to be read <br /> |

### onCharacteristicWriteRequest

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

```
public void onCharacteristicWriteRequest (BluetoothDevice device, 
                int requestId, 
                BluetoothGattCharacteristic characteristic, 
                boolean preparedWrite, 
                boolean responseNeeded, 
                int offset, 
                byte[] value)
```

A remote client has requested to write to a local characteristic.

An application must call `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#sendResponse(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20byte[])` to complete the request.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that has requested the write operation <br /> |
| `requestId` | `int`: The Id of the request <br /> |
| `characteristic` | `BluetoothGattCharacteristic`: Characteristic to be written to. <br /> |
| `preparedWrite` | `boolean`: true, if this write operation should be queued for later execution. <br /> |
| `responseNeeded` | `boolean`: true, if the remote device requires a response <br /> |
| `offset` | `int`: The offset given for the value <br /> |
| `value` | `byte`: The value the client wants to assign to the characteristic <br /> |

### onConnectionStateChange

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

```
public void onConnectionStateChange (BluetoothDevice device, 
                int status, 
                int newState)
```

Callback indicating when a remote device has been connected or disconnected.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: Remote device that has been connected or disconnected. <br /> |
| `status` | `int`: Status of the connect or disconnect operation. <br /> |
| `newState` | `int`: Returns the new connection state. Can be one of `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_DISCONNECTED` or `https://developer.android.com/reference/android/bluetooth/BluetoothProfile#STATE_CONNECTED` <br /> |

### onConnectionUpdated

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

```
public void onConnectionUpdated (BluetoothDevice device, 
                int interval, 
                int latency, 
                int supervisionTimeout, 
                int status)
```

Callback indicating the connection parameters were updated.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device involved. This value cannot be `null`. <br /> |
| `interval` | `int`: Connection interval used on this connection, 1.25ms unit. Valid range is from 6 (7.5ms) to 3200 (4000ms). Value is between 6 and 3200 inclusive <br /> |
| `latency` | `int`: Worker latency for the connection in number of connection events. Valid range is from 0 to 499. Value is between 0 and 499 inclusive <br /> |
| `supervisionTimeout` | `int`: Supervision timeout for this connection, in 10ms unit. Valid range is from 10 (0.1s) to 3200 (32s). Value is between 10 and 3200 inclusive <br /> |
| `status` | `int`: `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` if the connection has been updated successfully. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_READ_NOT_PERMITTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_WRITE_NOT_PERMITTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_INSUFFICIENT_AUTHENTICATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_REQUEST_NOT_SUPPORTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_INSUFFICIENT_ENCRYPTION` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_INVALID_OFFSET` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_INSUFFICIENT_AUTHORIZATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_INVALID_ATTRIBUTE_LENGTH` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_CONNECTION_CONGESTED` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_CONNECTION_TIMEOUT` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_FAILURE` |

### onDescriptorReadRequest

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

```
public void onDescriptorReadRequest (BluetoothDevice device, 
                int requestId, 
                int offset, 
                BluetoothGattDescriptor descriptor)
```

A remote client has requested to read a local descriptor.

An application must call `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#sendResponse(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20byte[])` to complete the request.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that has requested the read operation <br /> |
| `requestId` | `int`: The Id of the request <br /> |
| `offset` | `int`: Offset into the value of the characteristic <br /> |
| `descriptor` | `BluetoothGattDescriptor`: Descriptor to be read <br /> |

### onDescriptorWriteRequest

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

```
public void onDescriptorWriteRequest (BluetoothDevice device, 
                int requestId, 
                BluetoothGattDescriptor descriptor, 
                boolean preparedWrite, 
                boolean responseNeeded, 
                int offset, 
                byte[] value)
```

A remote client has requested to write to a local descriptor.

An application must call `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#sendResponse(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20byte[])` to complete the request.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that has requested the write operation <br /> |
| `requestId` | `int`: The Id of the request <br /> |
| `descriptor` | `BluetoothGattDescriptor`: Descriptor to be written to. <br /> |
| `preparedWrite` | `boolean`: true, if this write operation should be queued for later execution. <br /> |
| `responseNeeded` | `boolean`: true, if the remote device requires a response <br /> |
| `offset` | `int`: The offset given for the value <br /> |
| `value` | `byte`: The value the client wants to assign to the descriptor <br /> |

### onExecuteWrite

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

```
public void onExecuteWrite (BluetoothDevice device, 
                int requestId, 
                boolean execute)
```

Execute all pending write operations for this device.

An application must call `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#sendResponse(android.bluetooth.BluetoothDevice,%20int,%20int,%20int,%20byte[])` to complete the request.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that has requested the write operations <br /> |
| `requestId` | `int`: The Id of the request <br /> |
| `execute` | `boolean`: Whether the pending writes should be executed (true) or cancelled (false) <br /> |

### onMtuChanged

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

```
public void onMtuChanged (BluetoothDevice device, 
                int mtu)
```

Callback indicating the MTU for a given device connection has changed.

This callback will be invoked if a remote client has requested to change the MTU for a
given connection.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that requested the MTU change <br /> |
| `mtu` | `int`: The new MTU size <br /> |

### onNotificationSent

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

```
public void onNotificationSent (BluetoothDevice device, 
                int status)
```

Callback invoked when a notification or indication has been sent to a remote device.

When multiple notifications are to be sent, an application must wait for this callback to
be received before sending additional notifications.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device the notification has been sent to <br /> |
| `status` | `int`: `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` if the operation was successful <br /> |

### onPhyRead

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

```
public void onPhyRead (BluetoothDevice device, 
                int txPhy, 
                int rxPhy, 
                int status)
```

Callback triggered as result of `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#readPhy(android.bluetooth.BluetoothDevice)`

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device that requested the PHY read. <br /> |
| `txPhy` | `int`: the transmitter PHY in use. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_1M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_2M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_CODED` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_HDT` |
| `rxPhy` | `int`: the receiver PHY in use. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_1M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_2M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_CODED` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_HDT` |
| `status` | `int`: Status of the PHY read operation. `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` if the operation succeeds. <br /> |

### onPhyUpdate

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

```
public void onPhyUpdate (BluetoothDevice device, 
                int txPhy, 
                int rxPhy, 
                int status)
```

Callback triggered as result of `https://developer.android.com/reference/android/bluetooth/BluetoothGattServer#setPreferredPhy(android.bluetooth.BluetoothDevice,%20int,%20int,%20int)`, or as a result
of remote device changing the PHY.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device. <br /> |
| `txPhy` | `int`: the transmitter PHY in use. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_1M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_2M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_CODED` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_HDT` |
| `rxPhy` | `int`: the receiver PHY in use. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_1M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_2M` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_CODED` - `https://developer.android.com/reference/android/bluetooth/BluetoothDevice#PHY_LE_HDT` |
| `status` | `int`: Status of the PHY update operation. `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` if the operation succeeds. <br /> |

### onServiceAdded

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

```
public void onServiceAdded (int status, 
                BluetoothGattService service)
```

Indicates whether a local service has been added successfully.

<br />

| Parameters ||
|---|---|
| `status` | `int`: Returns `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` if the service was added successfully. <br /> |
| `service` | `BluetoothGattService`: The service that has been added <br /> |

### onSubrateChange

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

```
public void onSubrateChange (BluetoothDevice device, 
                int subrateMode, 
                int status)
```

Callback indicating LE connection's subrate parameters have changed.

<br />

| Parameters ||
|---|---|
| `device` | `BluetoothDevice`: The remote device involved. This value cannot be `null`. <br /> |
| `subrateMode` | `int`: for this LE connection. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#SUBRATE_MODE_OFF` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#SUBRATE_MODE_LOW` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#SUBRATE_MODE_BALANCED` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#SUBRATE_MODE_HIGH` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#SUBRATE_MODE_SYSTEM_UPDATE` - `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#SUBRATE_MODE_NOT_UPDATED` |
| `status` | `int`: `https://developer.android.com/reference/android/bluetooth/BluetoothGatt#GATT_SUCCESS` if the connection subrating has been updated successfully. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#SUCCESS` - `https://developer.android.com/reference/android/bluetooth/BluetoothStatusCodes#ERROR_UNKNOWN` |