0
votes

In my code, I'm trying to unpair a bluetooth device by calling the function.

import android.bluetooth.BluetoothDevice; .....

BluetoothDevice Device = mBluetoothAdapter.getRemoteDevice(address); .......

public void unpair() { int state = getBondState();

if (state == BluetoothDevice.BOND_BONDING || state == BluetoothDevice.BOND_BONDED) {

    Device.cancelBondProcess();  //Error in this line 

}
1

1 Answers

0
votes

Seems like you are using a non-public API cancelBondProcess(), In addition this APIs sounds like it will only cancel the process that is ongoing , i.e when the state is BOND_BONDING, if the device is already bonded it will fail / return error. You will need to removeBond() to remove the bonded device - again this is also non-public API and not recommended if you plan on keeping your application compatible with various versions of android releases.

There are no public APIs currently to accomplish canceling or removing of bond.