上图先

关于android中BLE编程BluetoothGattCallback.onServicesDiscovered不回调或部分回调解决方案

之前在BluetoothGattCallback.onConnectionStateChange中使用discoverServices()后BluetoothGattCallback.onServicesDiscovered不回调或部分回调,在网上搜寻到方案是在gatt.discoverServices()之前加延时也只能部分解决问题,当时估计应该是线程问题。后来将涉及到UI线程的控件更新去除,无需延时完美解决。

原因大概是因为该回调不是在UI线程中运行,故在该回调中使用其它线程有可能造成BluetoothGattCallback.onServicesDiscovered不回调或部分回调。如确有需要使用诸如UI线程操作,建议在该回调中使用Handler的message等方法。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-10-28
猜你喜欢
  • 2021-05-18
  • 2022-12-23
  • 2021-08-23
  • 2022-01-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案