BluetoothGattCallback
  public
  
  
  abstract
  class
  BluetoothGattCallback
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.bluetooth.BluetoothGattCallback | 
This abstract class is used to implement BluetoothGatt callbacks.
Summary
| Public constructors | |
|---|---|
| 
      BluetoothGattCallback()
       | |
| Public methods | |
|---|---|
| 
        
        
        
        
        
        void | 
      onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] value)
      Callback triggered as a result of a remote characteristic notification. | 
| 
        
        
        
        
        
        void | 
      onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
      
      This method was deprecated
      in API level 33.
    Use  | 
| 
        
        
        
        
        
        void | 
      onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] value, int status)
      Callback reporting the result of a characteristic read operation. | 
| 
        
        
        
        
        
        void | 
      onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
      
      This method was deprecated
      in API level 33.
    Use  | 
| 
        
        
        
        
        
        void | 
      onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
      Callback indicating the result of a characteristic write operation. | 
| 
        
        
        
        
        
        void | 
      onConnectionStateChange(BluetoothGatt gatt, int status, int newState)
      Callback indicating when GATT client has connected/disconnected to/from a remote GATT server. | 
| 
        
        
        
        
        
        void | 
      onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status, byte[] value)
      Callback reporting the result of a descriptor read operation. | 
| 
        
        
        
        
        
        void | 
      onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
      
      This method was deprecated
      in API level 33.
    Use  | 
| 
        
        
        
        
        
        void | 
      onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
      Callback indicating the result of a descriptor write operation. | 
| 
        
        
        
        
        
        void | 
      onMtuChanged(BluetoothGatt gatt, int mtu, int status)
      Callback indicating the MTU for a given device connection has changed. | 
| 
        
        
        
        
        
        void | 
      onPhyRead(BluetoothGatt gatt, int txPhy, int rxPhy, int status)
      Callback triggered as result of  | 
| 
        
        
        
        
        
        void | 
      onPhyUpdate(BluetoothGatt gatt, int txPhy, int rxPhy, int status)
      Callback triggered as result of  | 
| 
        
        
        
        
        
        void | 
      onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status)
      Callback reporting the RSSI for a remote device connection. | 
| 
        
        
        
        
        
        void | 
      onReliableWriteCompleted(BluetoothGatt gatt, int status)
      Callback invoked when a reliable write transaction has been completed. | 
| 
        
        
        
        
        
        void | 
      onServiceChanged(BluetoothGatt gatt)
      Callback indicating service changed event is received Receiving this event means that the GATT database is out of sync with the remote device. | 
| 
        
        
        
        
        
        void | 
      onServicesDiscovered(BluetoothGatt gatt, int status)
      Callback invoked when the list of remote services, characteristics and descriptors for the remote device have been updated, ie new services have been discovered. | 
| 
        
        
        
        
        
        void | 
      onSubrateChange(BluetoothGatt gatt, int subrateMode, int status)
      Callback indicating LE connection's subrate parameters have changed. | 
| Inherited methods | |
|---|---|
Public constructors
Public methods
onCharacteristicChanged
public void onCharacteristicChanged (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] value)
Callback triggered as a result of a remote characteristic notification. Note that the value within the characteristic object may have changed since receiving the remote characteristic notification, so check the parameter value for the value at the time of notification.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client the characteristic is associated with
 This value cannot benull. | 
| characteristic | BluetoothGattCharacteristic: Characteristic that has been updated as a result of a remote
     notification event.
 This value cannot benull. | 
| value | byte: notified characteristic value
 This value cannot benull. | 
onCharacteristicChanged
public void onCharacteristicChanged (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
      This method was deprecated
      in API level 33.
    Use BluetoothGattCallback.onCharacteristicChanged(BluetoothGatt,
     BluetoothGattCharacteristic, byte[]) as it is memory safe by providing the
     characteristic value at the time of notification.
  
Callback triggered as a result of a remote characteristic notification.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client the characteristic is associated with | 
| characteristic | BluetoothGattCharacteristic: Characteristic that has been updated as a result of a remote
     notification event. | 
onCharacteristicRead
public void onCharacteristicRead (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] value, int status)
Callback reporting the result of a characteristic read operation.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.readCharacteristic(android.bluetooth.BluetoothGattCharacteristic)This value cannot benull. | 
| characteristic | BluetoothGattCharacteristic: Characteristic that was read from the associated remote device.
 This value cannot benull. | 
| value | byte: the value of the characteristic
 This value cannot benull. | 
| status | int:BluetoothGatt.GATT_SUCCESSif the read operation was completed
     successfully. | 
onCharacteristicRead
public void onCharacteristicRead (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
      This method was deprecated
      in API level 33.
    Use BluetoothGattCallback.onCharacteristicRead(BluetoothGatt,
     BluetoothGattCharacteristic, byte[], int) as it is memory safe
  
Callback reporting the result of a characteristic read operation.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.readCharacteristic(android.bluetooth.BluetoothGattCharacteristic) | 
| characteristic | BluetoothGattCharacteristic: Characteristic that was read from the associated remote device. | 
| status | int:BluetoothGatt.GATT_SUCCESSif the read operation was completed
     successfully. | 
onCharacteristicWrite
public void onCharacteristicWrite (BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
Callback indicating the result of a characteristic write operation.
If this callback is invoked while a reliable write transaction is in progress, the value of the characteristic represents the value reported by the remote device. An application should compare this value to the desired value to be written. If the values don't match, the application must abort the reliable write transaction.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client that invokedBluetoothGatt.writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic, byte[], int) | 
| characteristic | BluetoothGattCharacteristic: Characteristic that was written to the associated remote device. | 
| status | int: The result of the write operationBluetoothGatt.GATT_SUCCESSif the
     operation succeeds. | 
onConnectionStateChange
public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState)
Callback indicating when GATT client has connected/disconnected to/from a remote GATT server.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client | 
| status | int: Status of the connect or disconnect operation.BluetoothGatt.GATT_SUCCESSif the operation succeeds. | 
| newState | int: Returns the new connection state. Can be one ofBluetoothProfile.STATE_DISCONNECTEDorBluetoothProfile.STATE_CONNECTED | 
onDescriptorRead
public void onDescriptorRead (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status, byte[] value)
Callback reporting the result of a descriptor read operation.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.readDescriptorThis value cannot benull. | 
| descriptor | BluetoothGattDescriptor: Descriptor that was read from the associated remote device.
 This value cannot benull. | 
| status | int:BluetoothGatt.GATT_SUCCESSif the read operation was completed
     successfully | 
| value | byte: the descriptor value at the time of the read operation
 This value cannot benull. | 
onDescriptorRead
public void onDescriptorRead (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
      This method was deprecated
      in API level 33.
    Use BluetoothGattCallback.onDescriptorRead(BluetoothGatt,
     BluetoothGattDescriptor, int, byte[]) as it is memory safe by providing the descriptor
     value at the time it was read.
  
Callback reporting the result of a descriptor read operation.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.readDescriptor | 
| descriptor | BluetoothGattDescriptor: Descriptor that was read from the associated remote device. | 
| status | int:BluetoothGatt.GATT_SUCCESSif the read operation was completed
     successfully | 
onDescriptorWrite
public void onDescriptorWrite (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status)
Callback indicating the result of a descriptor write operation.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.writeDescriptor | 
| descriptor | BluetoothGattDescriptor: Descriptor that was written to the associated remote device. | 
| status | int: The result of the write operationBluetoothGatt.GATT_SUCCESSif the
     operation succeeds. | 
onMtuChanged
public void onMtuChanged (BluetoothGatt gatt, int mtu, int status)
Callback indicating the MTU for a given device connection has changed.
This callback is triggered in response to the BluetoothGatt.requestMtu function,
 or in response to a connection event.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.requestMtu | 
| mtu | int: The new MTU size | 
| status | int:BluetoothGatt.GATT_SUCCESSif the MTU has been changed successfully | 
onPhyRead
public void onPhyRead (BluetoothGatt gatt, int txPhy, int rxPhy, int status)
Callback triggered as result of BluetoothGatt.readPhy
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client | 
| txPhy | int: the transmitter PHY in use. One ofBluetoothDevice.PHY_LE_1M,BluetoothDevice.PHY_LE_2M, andBluetoothDevice.PHY_LE_CODED. | 
| rxPhy | int: the receiver PHY in use. One ofBluetoothDevice.PHY_LE_1M,BluetoothDevice.PHY_LE_2M, andBluetoothDevice.PHY_LE_CODED. | 
| status | int: Status of the PHY read operation.BluetoothGatt.GATT_SUCCESSif the
     operation succeeds. | 
onPhyUpdate
public void onPhyUpdate (BluetoothGatt gatt, int txPhy, int rxPhy, int status)
Callback triggered as result of BluetoothGatt.setPreferredPhy, or as a result of
 remote device changing the PHY.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client | 
| txPhy | int: the transmitter PHY in use. One ofBluetoothDevice.PHY_LE_1M,BluetoothDevice.PHY_LE_2M, andBluetoothDevice.PHY_LE_CODED. | 
| rxPhy | int: the receiver PHY in use. One ofBluetoothDevice.PHY_LE_1M,BluetoothDevice.PHY_LE_2M, andBluetoothDevice.PHY_LE_CODED. | 
| status | int: Status of the PHY update operation.BluetoothGatt.GATT_SUCCESSif the
     operation succeeds. | 
onReadRemoteRssi
public void onReadRemoteRssi (BluetoothGatt gatt, int rssi, int status)
Callback reporting the RSSI for a remote device connection.
This callback is triggered in response to the BluetoothGatt.readRemoteRssi
 function.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.readRemoteRssi | 
| rssi | int: The RSSI value for the remote device | 
| status | int:BluetoothGatt.GATT_SUCCESSif the RSSI was read successfully | 
onReliableWriteCompleted
public void onReliableWriteCompleted (BluetoothGatt gatt, int status)
Callback invoked when a reliable write transaction has been completed.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.executeReliableWrite | 
| status | int:BluetoothGatt.GATT_SUCCESSif the reliable write transaction was
     executed successfully | 
onServiceChanged
public void onServiceChanged (BluetoothGatt gatt)
Callback indicating service changed event is received
Receiving this event means that the GATT database is out of sync with the remote device.
 BluetoothGatt.discoverServices should be called to re-discover the services.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client involved
 This value cannot benull. | 
onServicesDiscovered
public void onServicesDiscovered (BluetoothGatt gatt, int status)
Callback invoked when the list of remote services, characteristics and descriptors for the remote device have been updated, ie new services have been discovered.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: GATT client invokedBluetoothGatt.discoverServices | 
| status | int:BluetoothGatt.GATT_SUCCESSif the remote device has been explored
     successfully. | 
onSubrateChange
public void onSubrateChange (BluetoothGatt gatt, int subrateMode, int status)
Callback indicating LE connection's subrate parameters have changed.
| Parameters | |
|---|---|
| gatt | BluetoothGatt: The remote device involved
 This value cannot benull. | 
| subrateMode | int: for this LE connection.
 Value isBluetoothGatt.SUBRATE_MODE_OFF,BluetoothGatt.SUBRATE_MODE_LOW,BluetoothGatt.SUBRATE_MODE_BALANCED,BluetoothGatt.SUBRATE_MODE_HIGH,BluetoothGatt.SUBRATE_MODE_SYSTEM_UPDATE, orBluetoothGatt.SUBRATE_MODE_NOT_UPDATED | 
| status | int:BluetoothGatt.GATT_SUCCESSif the connection subrating has been updated
     successfully
 Value isBluetoothStatusCodes.SUCCESS, android.bluetooth.BluetoothStatusCodes.REASON_SYSTEM_POLICY,BluetoothStatusCodes.ERROR_UNKNOWN, android.bluetooth.BluetoothStatusCodes.ERROR_HARDWARE_GENERIC, android.bluetooth.BluetoothStatusCodes.NOT_ALLOWED, android.bluetooth.BluetoothStatusCodes.ERROR_REMOTE_OPERATION_NOT_SUPPORTED, android.bluetooth.BluetoothStatusCodes.ERROR_LOCAL_NOT_ENOUGH_RESOURCES, or android.bluetooth.BluetoothStatusCodes.ERROR_BAD_PARAMETERS | 
