I am currently developing a BLE-enabled Android app targeting API 27 using Kotlin.
I am attempting to override a function within android.bluetooth.BluetoothGatt
. There are a number of callbacks available to be overridden to enable the handling of certain BLE events.
For example, I override onConnectionStateChange()
in the following way:
private val bluetoothGattCallback = object : BluetoothGattCallback() {
override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
/* do stuff */
}
This works just fine.
My issue stems from trying to override onConnectionUpdated()
. This callback is defined in the same way as onConnectionStateChange()
in the BLE API source, so how come I can't override it? This is how I am attempting to override it (still within the BluetoothGattCallback()
object):
fun onConnectionUpdated(gatt: BluetoothGatt, interval: Int, latency: Int, timeout: Int, status: Int) {
/* do stuff */
}
EDIT: I forgot to mention that, when I add the
override
keyword it provides the error message:OnConnectionUpdated overrides nothing.
.
Forgive my naivety, I don't often work with Kotlin/Java, thanks.