Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android characteristic.getValue空数组_Android_Bluetooth Lowenergy_Android Bluetooth_Gatt_Bluetooth Gatt - Fatal编程技术网

Android characteristic.getValue空数组

Android characteristic.getValue空数组,android,bluetooth-lowenergy,android-bluetooth,gatt,bluetooth-gatt,Android,Bluetooth Lowenergy,Android Bluetooth,Gatt,Bluetooth Gatt,有时,如果发生GATT通知,并且我多次尝试通过characteristic.getValue()获取特征值,则调用会突然开始返回空数组 这主要发生在这方面的第一次通知上,而且似乎是随机的 如何使characteristic.getValue()保持一致 我有一个像素3;可能这是一个实现问题。每个通知只应调用characteristic.getValue()一次,并将其存储在某个变量中。您不应该每次需要引用该数据时都调用它。如果您在一次通知后多次调用该功能,则该功能将不起作用 理想情况下,您使用的

有时,如果发生GATT通知,并且我多次尝试通过
characteristic.getValue()
获取特征值,则调用会突然开始返回空数组

这主要发生在这方面的第一次通知上,而且似乎是随机的

如何使
characteristic.getValue()
保持一致


我有一个像素3;可能这是一个实现问题。

每个通知只应调用
characteristic.getValue()
一次,并将其存储在某个变量中。您不应该每次需要引用该数据时都调用它。如果您在一次通知后多次调用该功能,则该功能将不起作用


理想情况下,您使用的是Google提供的服务示例,并将通知数据推送到所需活动中的变量。这将在对所需特性使用
setCharacteristicNotification
后自动发生,并且每当收到通知广播时,都会在
broadcastUpdate
中执行更新。(假设您在应用程序中连接了“管道”)

谢谢您的回答,尽管这对我来说是新的。看起来它真的是我堆栈中的一个bug。你有官方消息来源证实你的说法吗?