语言

BluetoothDevice.CreateRfcommSocketToServiceRecord(UUID) 方法

定义

使用 Uuid 的 SDP 查找创建一个 RFCOMM BluetoothSocket ,以便启动到此远程设备的安全传出连接。

[Android.Runtime.Register("createRfcommSocketToServiceRecord", "(Ljava/util/UUID;)Landroid/bluetooth/BluetoothSocket;", "")]
public Android.Bluetooth.BluetoothSocket? CreateRfcommSocketToServiceRecord(Java.Util.UUID? uuid);
[<Android.Runtime.Register("createRfcommSocketToServiceRecord", "(Ljava/util/UUID;)Landroid/bluetooth/BluetoothSocket;", "")>]
member this.CreateRfcommSocketToServiceRecord : Java.Util.UUID -> Android.Bluetooth.BluetoothSocket

参数

uuid
UUID

用于查找 RFCOMM 通道的服务记录 uuid

返回

用于传出连接的 RFCOMM BluetoothServerSocket

特性

例外

出错时,例如蓝牙不可用或权限不足

注解

使用 Uuid 的 SDP 查找创建一个 RFCOMM BluetoothSocket ,以便启动到此远程设备的安全传出连接。

这设计用于 BluetoothAdapter#listenUsingRfcommWithServiceRecord 对等蓝牙应用程序。

用于 BluetoothSocket#connect 启动传出连接。 这还将执行给定 uuid 的 SDP 查找,以确定要连接到的通道。

远程设备将进行身份验证,并将对此套接字上的通信进行加密。

仅当有可能使用经过身份验证的套接字链接时,才使用此套接字。 身份验证是指链接密钥的身份验证,以防止中间人受到攻击。 例如,对于蓝牙 2.1 设备,如果任何设备没有输入和输出功能,或者只能够显示数字键,则无法建立安全套接字连接。 在这种情况下,请使用 #createInsecureRfcommSocketToServiceRecord。 有关更多详细信息,请参阅蓝牙核心规范版本 2.1 + EDR 的安全模型部分 5.2(第 3 卷)。

提示:如果要连接到蓝牙串行板,请尝试使用已知的 SPP UUID 00001101-0000-1000-8000-00805F9B34FB。 但是,如果要连接到 Android 对等方,请生成自己的唯一 UUID。

Java文档android.bluetooth.BluetoothDevice.createRfcommSocketToServiceRecord(java.util.UUID)。

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于