Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bluetooth - How to initiate Pairing

I want to initiate a pairing request (not connection at this point of time) to a non android device. This can be found working on Settings Application > Network > Bluetooth Settings > Click on a device after scan. A pop up appears on both the devices with a 6 digit pin.

As per Android's documentation this should have popped up in my application as well, if I do something like this

device.createRfcommSocketToServiceRecord(MY_UUID);

As per Android's API documentation

"Once a connection is made with a remote device for the first time, a pairing request is automatically presented to the user."

And it is also mentioned that

"The current Android Bluetooth API's require devices to be paired before an RFCOMM connection can be established. (Pairing is automatically performed when you initiate an encrypted connection with the Bluetooth APIs.)"

Even when I used the sample Bluetooth Chat application (only to test if it initiates a pairing on first connection) it didn't worked.

I also tried using a generic UDID like "00001101-0000-1000-8000-00805F9B34FB" but to no avail.

Couldn't find the source code of Settings Application (Android OS 2.1) to figure out myself. The sources available in Android GIT were for Android 2.3

Even if you cannot answer the question, only pointing out to Android Packages Settings App sources for Android 2.1 might do the trick for me.

like image 718
Rahul Choudhary Avatar asked Oct 12 '22 05:10

Rahul Choudhary


1 Answers

It works for me with this UUID : "00001101-0000-1000-8000-00805F9B34FB". The intent for pairing request is launched when you call socket.connect() if I remember correctly.

like image 196
roly Avatar answered Oct 18 '22 02:10

roly