Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should we invoke setPin() for bluetooth pairing in android?

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 !

like image 918
Babu Prasad Avatar asked Jun 25 '14 20:06

Babu Prasad


1 Answers

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

like image 152
Timmmm Avatar answered Oct 21 '22 04:10

Timmmm