语言

BluetoothGatt.SetCharacteristicNotification 方法

定义

启用或禁用给定特征的通知/指示。

[Android.Runtime.Register("setCharacteristicNotification", "(Landroid/bluetooth/BluetoothGattCharacteristic;Z)Z", "")]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")]
public bool SetCharacteristicNotification(Android.Bluetooth.BluetoothGattCharacteristic? characteristic, bool enable);
[<Android.Runtime.Register("setCharacteristicNotification", "(Landroid/bluetooth/BluetoothGattCharacteristic;Z)Z", "")>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")>]
member this.SetCharacteristicNotification : Android.Bluetooth.BluetoothGattCharacteristic * bool -> bool

参数

characteristic
BluetoothGattCharacteristic

要为其启用通知的特征

enable
Boolean

设置为 true 以启用通知/指示

返回

如果已成功设置请求的通知状态,则为 true

特性

注解

启用或禁用给定特征的通知/指示。

为特征启用通知后,如果远程设备指示给定的特征已更改, BluetoothGattCallback#onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic, byte[]) 将触发回调。

Java文档android.bluetooth.BluetoothGatt.setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean)。

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

适用于