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.
You should not use this method, it is only for internal use and not part of the public API. Therefore it is hidden via
@hide
. For more information about@hide
and how to access it regardless see What does @hide mean in the Android source code?Note that using reflection to access it as described in the link above is discouraged
The method you want to use is on the dark-greylist with the following restrictions: