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 !