【发布时间】:2017-05-05 09:09:18
【问题描述】:
我正在使用 Android ble 开发应用程序。该应用程序将使用 ble 与外部设备连接。外部设备有一个记录数据的传感器,一旦安卓设备进入范围,数据传输就开始了。 android 应用程序将注册以在特定特征发生变化时得到通知,并且当两个设备连接时,数据通过传输
setCharacteristicNoification() --> onCharactericticChanged()
现在这适用于传感器在 5-10 分钟内收集的数据。但是,如果设备超出范围超过 15 分钟,并且现在必须传输所有这些数据,则应用程序会自行退出。
在几个论坛上阅读有关此内容时,我检查了系统日志并发现此错误:
BluetoothServiceJni: An exception was thrown by callback 'btgattc_notify_cb'.
BluetoothServiceJni: android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:496)
at android.bluetooth.IBluetoothGattCallback$Stub$Proxy.onNotify(IBluetoothGattCallback.java:840)
at com.android.bluetooth.gatt.GattService.onNotify(GattService.java:838)
多次重复此异常消息后,我收到此消息
BtGatt.AdvertiseManager: stop advertise for client 5
BtGatt.GattService: onAdvertiseInstanceDisabled() - clientIf=5, status=0
BtGatt.GattService: Client app is not null!
BtGatt.AdvertiseManager: failed onAdvertiseInstanceDisabled
android.os.DeadObjectException at
android.os.BinderProxy.transactNative(Native Method) at
android.os.BinderProxy.transact(Binder.java:496) at android.bluetooth.IBluetoothGattCallback$Stub$Proxy.onMultiAdvertiseCallback(IBluetoothGattCallback.java:874)at com.android.bluetooth.gatt.GattService.onAdvertiseInstanceDisabled(GattService.java:1242) at com.android.bluetooth.gatt.AdvertiseManager$AdvertiseNative.stopAdvertising(AdvertiseManager.java:318)at com.android.bluetooth.gatt.AdvertiseManager$ClientHandler.handleStopAdvertising(AdvertiseManager.java:212) at com.android.bluetooth.gatt.AdvertiseManager$ClientHandler.handleMessage(AdvertiseManager.java:175) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.os.HandlerThread.run(HandlerThread.java:61)
BtGatt.AdvertiseManager: app died - unregistering client : 5
最后是这条消息:
BtGatt.ContextMap: Context not found for ID 5
我不确定我的代码有什么问题,以及代码的哪一部分导致了这个问题。 谁能解释一下这个问题可能是什么?
【问题讨论】:
标签: java android bluetooth bluetooth-lowenergy android-ble