我们应该在android中调用setPin()进行蓝牙配对?

时间:2014-06-25 20:22:09

标签: java android bluetooth android-bluetooth

我们应该在哪里插入setPin(String pin)来配对蓝牙设备?应该在createBond之前还是在

之后调用该函数

这篇文章中的答案Howt to connect two devices via bluetooth sending the pairng code by parameter? JAVA-Android表示应该在调用createBond()

之前调用它

但问题How can I avoid or dismiss Android's Bluetooth pairing notification when I am doing programmatic pairing?说明了完成蓝牙配对的步骤,setPin之后调用了createBond()。如果这样做,那么它应该在BroadcastReceiver中调用,我们在那里获得配对请求的回调。

哪种方法正确?真的很困惑!

1 个答案:

答案 0 :(得分:2)

我发现some test code似乎建议您在createBond() in response to the BluetoothDevice.ACTION_PAIRING_REQUEST broadcast后调用它。