开发者

unable to call the function "cancelBondProcess()"

开发者 https://www.devze.com 2023-02-17 08:12 出处:网络
In my code, I\'m trying to unpair a bluetooth device by calling the function. import android.bluetooth.BluetoothDevice;

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 vo开发者_JS百科id unpair() { int state = getBondState();

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

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

}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消