我们应该在哪里插入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中调用,我们在那里获得配对请求的回调。
哪种方法正确?真的很困惑!
答案 0 :(得分:2)
我发现some test code似乎建议您在createBond()
in response to the BluetoothDevice.ACTION_PAIRING_REQUEST
broadcast后调用它。