Where should we insert setPin(String pin)
for pairing a bluetooth device? should the function be invoked before createBond
or after ??
Answer in this post Howt to connect two devices via bluetooth sending the pairng code by parameter? JAVA-Android conveys that it should be called before invoking createBond()
But the question How can I avoid or dismiss Android's Bluetooth pairing notification when I am doing programmatic pairing? tells the steps in which the bluetooth pairing is done in which the setPin
is called after createBond()
. If this works, then it should be invoked inside BroadcastReceiver where we get callback for pairing request.
Which is the right approach? Am really confused !
I found some test code that seems to suggest you call it after createBond()
in response to the BluetoothDevice.ACTION_PAIRING_REQUEST
broadcast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With