I can use the following code to unbind, but how do I simply perform disconnection?
val pair = device.javaClass.getMethod("removeBond")
pair.isAccessible = true
pair.invoke(device)
I use this connection function to connect my headset.
val connectMethod = BluetoothA2dp::class.java.getMethod("connect", BluetoothDevice::class.java)
connectMethod.isAccessible = true
connectMethod.invoke(btA2dp, device)
I refer to this post but still not working for me.