I am using Android API 27 and Kotlin and wish to override a BLE callback that is hidden via @hide
. This question follows on from a previous question of mine. The callback in question is onConnectionUpdated
and is defined within BluetoothGatt.java. The callback function is also defined within BluetoothGattCallback.java, so I'm not even sure which version I need to override.
I understand that I need to use reflection to access hidden member functions of a class, but I can't figure out how to actually access the function and override it.
Here's what I am attempting, to no avail:
val kclass = Class.forName("android.bluetooth.BluetoothGatt")
val kmethod = kclass.getMethod("onConnectionUpdated")
override fun kmethod(gatt: BluetoothGatt, interval: Int, latency: Int, timeout: Int, status: Int) {
/* do stuff */
}
The error in this instance is:
kmethod overrides nothing
.
I understand that I can also use Kotlin's reflection library, but again, I'm not sure how to.
Thanks.