Android 蓝牙 - 如何启动配对

标签 android bluetooth

我想向非安卓设备发起配对请求(此时不是连接)。这可以在“设置应用程序”>“网络”>“蓝牙设置”>“扫描后单击设备”上找到。两个设备上都会出现一个带有 6 位数 PIN 的弹出窗口。

根据 Android 的文档,如果我这样做,这也应该在我的应用程序中弹出

device.createRfcommSocketToServiceRecord(MY_UUID);

根据 Android 的 API 文档

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

还提到了

"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.)"

即使我使用示例蓝牙聊天应用程序(只是为了测试它是否在第一次连接时启动配对)它也没有工作。

我也尝试使用像“00001101-0000-1000-8000-00805F9B34FB”这样的通用 UDID,但无济于事。

无法找到设置应用程序(Android OS 2.1)的源代码来弄清楚自己。 Android GIT 中可用的源代码适用于 Android 2.3

即使您无法回答问题,仅指出适用于 Android 2.1 的 Android Packages Settings 应用程序源也可能对我有用。

最佳答案

它适用于此 UUID:“00001101-0000-1000-8000-00805F9B34FB”。 如果我没记错的话,配对请求的 Intent 是在您调用 socket.connect() 时启动的。

关于Android 蓝牙 - 如何启动配对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5764958/

相关文章:

android - 未解析的引用 : SavedStateVMFactory

linux - 低功耗蓝牙 : listening for notifications/indications in linux

java - 找不到包 android.bluetooth

Android NearBy API 非常慢(发现和连接约 10 秒以上)

ubuntu - 使用蓝牙 HID 代理模式 Ubuntu 15.10 的问题

android - Ionic + Capacitor 3 + Android 短暂显示扭曲的启动画面

android - 剪切视频时找不到合适的输出格式

android - 以编程方式删除 ViewPager,何时(或如何确保)包含的 fragment 被销毁?

android - 从移动蓝牙打印机 (ESC/POS) 请求电池状态

Android 6.0 权限对话框未显示