How to disconnect the bound bluetooth device in Android

117 Views Asked by At

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.

0

There are 0 best solutions below