BluetoothGattServer.Connect(BluetoothDevice, Boolean) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
启动与支持蓝牙 GATT 的设备的连接。
[Android.Runtime.Register("connect", "(Landroid/bluetooth/BluetoothDevice;Z)Z", "")]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")]
public bool Connect(Android.Bluetooth.BluetoothDevice? device, bool autoConnect);
[<Android.Runtime.Register("connect", "(Landroid/bluetooth/BluetoothDevice;Z)Z", "")>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")>]
member this.Connect : Android.Bluetooth.BluetoothDevice * bool -> bool
参数
- device
- BluetoothDevice
- autoConnect
- Boolean
是直接连接到远程设备(false),还是一旦远程设备可用(true)即可自动连接。
返回
如果成功启动连接尝试,则为 true
- 特性
注解
启动与支持蓝牙 GATT 的设备的连接。
连接可能不会立即建立,但将在远程设备可用时完成。
BluetoothGattServerCallback#onConnectionStateChange当连接状态因此函数而更改时,将调用回调。
autoConnect 参数确定是主动连接到远程设备,还是被动扫描并在远程设备处于可用范围/可用时完成连接。 通常,与设备的第一次连接应为直接(autoConnect 设置为 false),并且应调用与已知设备的后续连接,并将 autoConnect 参数设置为 true。
Java文档android.bluetooth.BluetoothGattServer.connect(android.bluetooth.BluetoothDevice, boolean)。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。