Android Bluetooth - How to initiate Pairing

余生长醉 提交于 2020-02-20 09:09:37

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5764958/android-bluetooth-how-to-initiate-pairing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!