HarmonyOS调用 gattClient.off('BLECharacteristicChange') 项目闪退

闪退日志:

1 
PID = 30380 
UID = 20020128 
TID = 30308 
App main thread is not response! 
mainHandler dump is: 
  EventHandler dump begin curTime: 2024-05-08 02:48:22.109 
Event runner (Thread name = , Thread ID = 30380) is running 
Current Running: start at 2024-05-08 02:48:17.958, Event { send thread = 30380, send time = 2024-05-08 02:48:17.958, handle time = 2024-05-08 02:48:17.958, task name = uvLoopTask } 
History event queue information: 
  No. 0 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.848, handle time = 2024-05-08 02:48:17.848, trigger time = 2024-05-08 02:48:17.848, completeTime time = 2024-05-08 02:48:17.849, task name = vSyncTask } 
No. 1 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.799, handle time = 2024-05-08 02:48:17.850, trigger time = 2024-05-08 02:48:17.850, completeTime time = 2024-05-08 02:48:17.850, task name =  } 
No. 2 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.856, handle time = 2024-05-08 02:48:17.856, trigger time = 2024-05-08 02:48:17.856, completeTime time = 2024-05-08 02:48:17.857, task name = vSyncTask } 
No. 3 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.807, handle time = 2024-05-08 02:48:17.858, trigger time = 2024-05-08 02:48:17.858, completeTime time = 2024-05-08 02:48:17.858, task name =  } 
No. 4 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.864, handle time = 2024-05-08 02:48:17.865, trigger time = 2024-05-08 02:48:17.865, completeTime time = 2024-05-08 02:48:17.866, task name = vSyncTask } 
No. 5 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.565, handle time = 2024-05-08 02:48:17.865, trigger time = 2024-05-08 02:48:17.866, completeTime time = 2024-05-08 02:48:17.868, task name = uv_timer_task } 
No. 6 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.816, handle time = 2024-05-08 02:48:17.867, trigger time = 2024-05-08 02:48:17.868, completeTime time = 2024-05-08 02:48:17.868, task name =  } 
No. 7 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.871, handle time = 2024-05-08 02:48:17.871, trigger time = 2024-05-08 02:48:17.871, completeTime time = 2024-05-08 02:48:17.872, task name = uvLoopTask } 
No. 8 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.873, handle time = 2024-05-08 02:48:17.873, trigger time = 2024-05-08 02:48:17.873, completeTime time = 2024-05-08 02:48:17.874, task name = vSyncTask } 
No. 9 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.825, handle time = 2024-05-08 02:48:17.876, trigger time = 2024-05-08 02:48:17.876, completeTime time = 2024-05-08 02:48:17.876, task name =  } 
No. 10 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.881, handle time = 2024-05-08 02:48:17.881, trigger time = 2024-05-08 02:48:17.881, completeTime time = 2024-05-08 02:48:17.882, task name = vSyncTask } 
No. 11 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.833, handle time = 2024-05-08 02:48:17.884, trigger time = 2024-05-08 02:48:17.884, completeTime time = 2024-05-08 02:48:17.884, task name =  } 
No. 12 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.889, handle time = 2024-05-08 02:48:17.889, trigger time = 2024-05-08 02:48:17.889, completeTime time = 2024-05-08 02:48:17.891, task name = vSyncTask } 
No. 13 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.841, handle time = 2024-05-08 02:48:17.892, trigger time = 2024-05-08 02:48:17.893, completeTime time = 2024-05-08 02:48:17.893, task name =  } 
No. 14 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.898, handle time = 2024-05-08 02:48:17.898, trigger time = 2024-05-08 02:48:17.898, completeTime time = 2024-05-08 02:48:17.899, task name = vSyncTask } 
No. 15 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.848, handle time = 2024-05-08 02:48:17.899, trigger time = 2024-05-08 02:48:17.900, completeTime time = 2024-05-08 02:48:17.900, task name =  } 
No. 16 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.906, handle time = 2024-05-08 02:48:17.906, trigger time = 2024-05-08 02:48:17.906, completeTime time = 2024-05-08 02:48:17.907, task name = vSyncTask } 
No. 17 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.857, handle time = 2024-05-08 02:48:17.908, trigger time = 2024-05-08 02:48:17.908, completeTime time = 2024-05-08 02:48:17.908, task name =  } 
No. 18 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.914, handle time = 2024-05-08 02:48:17.914, trigger time = 2024-05-08 02:48:17.914, completeTime time = 2024-05-08 02:48:17.916, task name = vSyncTask } 
No. 19 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.866, handle time = 2024-05-08 02:48:17.917, trigger time = 2024-05-08 02:48:17.918, completeTime time = 2024-05-08 02:48:17.918, task name =  } 
No. 20 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.918, handle time = 2024-05-08 02:48:17.918, trigger time = 2024-05-08 02:48:17.918, completeTime time = 2024-05-08 02:48:17.919, task name = uvLoopTask } 
No. 21 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.923, handle time = 2024-05-08 02:48:17.923, trigger time = 2024-05-08 02:48:17.923, completeTime time = 2024-05-08 02:48:17.924, task name = vSyncTask } 
No. 22 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.873, handle time = 2024-05-08 02:48:17.924, trigger time = 2024-05-08 02:48:17.925, completeTime time = 2024-05-08 02:48:17.925, task name =  } 
No. 23 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.931, handle time = 2024-05-08 02:48:17.931, trigger time = 2024-05-08 02:48:17.931, completeTime time = 2024-05-08 02:48:17.933, task name = vSyncTask } 
No. 24 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.882, handle time = 2024-05-08 02:48:17.933, trigger time = 2024-05-08 02:48:17.933, completeTime time = 2024-05-08 02:48:17.933, task name =  } 
No. 25 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.939, handle time = 2024-05-08 02:48:17.939, trigger time = 2024-05-08 02:48:17.939, completeTime time = 2024-05-08 02:48:17.941, task name = vSyncTask } 
No. 26 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.890, handle time = 2024-05-08 02:48:17.941, trigger time = 2024-05-08 02:48:17.942, completeTime time = 2024-05-08 02:48:17.942, task name =  } 
No. 27 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.948, handle time = 2024-05-08 02:48:17.948, trigger time = 2024-05-08 02:48:17.948, completeTime time = 2024-05-08 02:48:17.949, task name = vSyncTask } 
No. 28 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.899, handle time = 2024-05-08 02:48:17.950, trigger time = 2024-05-08 02:48:17.950, completeTime time = 2024-05-08 02:48:17.950, task name =  } 
No. 29 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.956, handle time = 2024-05-08 02:48:17.956, trigger time = 2024-05-08 02:48:17.956, completeTime time = 2024-05-08 02:48:17.958, task name = vSyncTask } 
No. 30 : Event { send thread = 30380, send time = 2024-05-08 02:48:17.907, handle time = 2024-05-08 02:48:17.958, trigger 
HarmonyOS
2024-09-06 12:18:44
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

可以参考以下代码:

import { BusinessError } from '@ohos.base'; 
try { 
  let device: ble.GattClientDevice = ble.createGattClientDevice('XX:XX:XX:XX:XX:XX'); 
  device.off('BLECharacteristicChange'); 
} catch (err) { 
  console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message); 
}

同时需要开启权限

ohos.permission.ACCESS_BLUETOOTH

参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-bluetooth-ble-V5#offblecharacteristicchange

分享
微博
QQ
微信
回复
2024-09-06 15:07:38
相关问题
HarmonyOS应用退问题
589浏览 • 1回复 待解决
HarmonyOS 页面返回时应用退报错
450浏览 • 1回复 待解决
打开图库应用时偶尔会退
2372浏览 • 0回复 待解决
加载FFMpeg后APP出现退
96浏览 • 1回复 待解决
鸿蒙js开发 文件交互Api 退
6483浏览 • 2回复 待解决
HarmonyOS NEXT Developer Beta1模拟器退
1425浏览 • 1回复 待解决
退和报错日记获取有了解的吗?
2723浏览 • 1回复 待解决
屏幕右移有时退软件还退不出来
5960浏览 • 1回复 待解决
ArkTS项目如何调用已有SO库?
840浏览 • 1回复 待解决
hilog -p off 在IDE中怎么关
294浏览 • 1回复 待解决
HarmonyOS video设置加载图
222浏览 • 1回复 待解决
系统监听注册的on和off的用法问题
1797浏览 • 1回复 待解决