纽轱辘小铭 2023-06-08 11:11 采纳率: 88.9%
浏览 21
已结题

ble蓝牙配对成功后,远距离断开蓝牙后,再回近距离搜索不到蓝牙名称也无法配对成功

Android studio ble蓝牙配对成功后,远距离断开蓝牙后,再回近距离搜索不到蓝牙名称也无法配对成功,是什么情况?
以下是报错信息


```java

E/TestSerice2: onConnectionStateChange fail-->(连接状态更改)0
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=14
D/BluetoothGatt: cancelOpen() - device: 94:C9:60:**:**:**
W/BluetoothGatt: Unhandled exception in callback
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.bluetooth.BluetoothGatt android.bluetooth.BluetoothDevice.connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback)' on a null object reference
        at com.example.myapplication.TestService2$3.onConnectionStateChange(TestService2.java:209)
        at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:280)
        at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:794)
        at android.bluetooth.BluetoothGatt.access$400(BluetoothGatt.java:42)
        at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:275)
        at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:192)
        at android.os.Binder.execTransactInternal(Binder.java:1028)
        at android.os.Binder.execTransact(Binder.java:1001)
D/DecorView: showOrHideHighlightView: hasFocus=true; winMode=1; isMrgNull=true


  • 写回答

2条回答 默认 最新

  • 於黾 2023-06-08 11:19
    关注

    callback里使用的对象已经关闭了
    执行收发之前先判断非空

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月3日
  • 已采纳回答 7月26日
  • 创建了问题 6月8日

悬赏问题

  • ¥20 如何在 rocky9.4 部署 CDH6.3.2?
  • ¥35 navicat将excel中的数据导入mysql出错
  • ¥15 rt-thread线程切换的问题
  • ¥20 python忆阻器数字识别
  • ¥15 高通uboot 打印ubi init err 22
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api