8

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 !

Community
  • 1
  • 1
Babu Prasad
  • 344
  • 4
  • 12

1 Answers1

4

I found some test code that seems to suggest you call it after createBond() in response to the BluetoothDevice.ACTION_PAIRING_REQUEST broadcast.

Timmmm
  • 88,195
  • 71
  • 364
  • 509