on Characteristic Changed
Called when a characteristic value has changed due to a notification or indication (API 33+).
This modern callback is invoked on Android 13 (API 33) and later. The characteristic value is passed directly as a parameter, which is safer than reading from the characteristic object and avoids potential race conditions.
Parameters
The BluetoothGatt instance for the connection.
The BluetoothGattCharacteristic whose value has changed.
The new value of the characteristic as a ByteArray.
See also
Deprecated
Deprecated in API 33. Use onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic, ByteArray) instead.
Replace with
onCharacteristicChanged(gatt, characteristic, value)Called when a characteristic value has changed due to a notification or indication (API < 33).
This legacy callback is invoked on Android versions prior to API 33 (Android 13). The characteristic value must be retrieved from the characteristic object itself.
Note: This method is deprecated in favor of the API 33+ variant that passes the value directly as a parameter, avoiding potential race conditions.
Parameters
The BluetoothGatt instance for the connection.
The BluetoothGattCharacteristic whose value has changed. Call BluetoothGattCharacteristic.getValue to retrieve the new value.