我正在使用 Radius Networks 开源 Android iBeacon 库,由于某种原因,它有时只是停止工作,也就是说,它工作正常,然后没有任何明显的原因它停止测距,或者至少它看起来正在发生。我在使用他们的 iBeacon Locate 应用时遇到过同样的行为。
发生此问题时,关闭和打开应用程序无济于事。为了让应用程序再次正常工作,我必须关闭应用程序,禁用蓝牙,打开应用程序(因此应用程序抱怨蓝牙被禁用),启用蓝牙,然后再次打开应用程序。
当应用程序启动并正常工作以及不能正常工作时,我已经捕获了 LogCat,并且我注意到两者之间的一些差异可能会为正在发生的事情提供线索。
LogCat 何时启动并正常工作:
07-07 19:51:54.519: D/IBeaconManager(1490): we have a connection to the service now
07-07 19:51:54.629: I/IBeaconService(1490): start ranging received
07-07 19:51:54.629: I/ActivityManager(592): Displayed com.core.vordrawer/.MainActivity: +654ms (total +999ms)
07-07 19:51:54.629: D/BluetoothAdapter(1490): startLeScan(): null
07-07 19:51:54.669: D/BtGatt.GattService(11998): registerClient() - UUID=2c657179-3c94-4f2f-9c0b-2035f646b8a4
07-07 19:51:54.669: D/BtGatt.btif(11998): btif_gattc_register_app
07-07 19:51:54.669: D/BtGatt.btif(11998): btgattc_handle_event: Event 1000
07-07 19:51:54.669: D/BtGatt.btif(11998): btif_gattc_upstreams_evt: Event 0
07-07 19:51:54.669: D/BtGatt.GattService(11998): onClientRegistered() - UUID=2c657179-3c94-4f2f-9c0b-2035f646b8a4, clientIf=5
07-07 19:51:54.669: D/BluetoothAdapter(1490): onClientRegistered() - status=0 clientIf=5
07-07 19:51:54.669: D/BtGatt.GattService(11998): startScan() - queue=0
07-07 19:51:54.669: D/BtGatt.GattService(11998): startScan() - adding client=5
07-07 19:51:54.669: D/BtGatt.btif(11998): btif_gattc_scan
07-07 19:51:54.669: D/BtGatt.btif(11998): btgattc_handle_event: Event 1002
07-07 19:51:54.689: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.689: I/bt-hci(11998): btu_ble_process_adv_pkt
07-07 19:51:54.689: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.689: I/bt-hci(11998): btu_ble_process_adv_pkt
07-07 19:51:54.699: I/bt-hci(11998): BLE HCI(id=62) event = 0x02)
07-07 19:51:54.699: I/bt-hci(11998): btu_ble_process_adv_pkt
07-07 19:51:54.699: D/BtGatt.btif(11998): btif_gattc_upstreams_evt: Event 4096
07-07 19:51:54.699: D/BtGatt.btif(11998): btif_gattc_add_remote_bdaddr device added idx=0
...
LogCat 启动时无法正常工作:
07-07 19:58:48.270: D/IBeaconManager(4630): we have a connection to the service now
07-07 19:58:48.380: I/IBeaconService(4630): start ranging received
07-07 19:58:48.380: D/BluetoothAdapter(4630): startLeScan(): null
07-07 19:58:48.390: I/ActivityManager(592): Displayed com.core.vordrawer/.MainActivity: +644ms (total +846ms)
07-07 19:58:48.420: D/BtGatt.GattService(11998): registerClient() - UUID=33ecc2dc-ee8f-4bb1-b306-e5a2b82a1cba
07-07 19:58:48.420: D/BtGatt.btif(11998): btif_gattc_register_app
07-07 19:58:48.420: D/BtGatt.btif(11998): btgattc_handle_event: Event 1000
07-07 19:58:48.420: D/BtGatt.btif(11998): btif_gattc_upstreams_evt: Event 0
07-07 19:58:48.420: D/BtGatt.GattService(11998): onClientRegistered() - UUID=33ecc2dc-ee8f-4bb1-b306-e5a2b82a1cba, clientIf=7
07-07 19:58:48.420: D/BluetoothAdapter(4630): onClientRegistered() - status=0 clientIf=7
07-07 19:58:48.420: D/BtGatt.GattService(11998): startScan() - queue=0
07-07 19:58:48.420: D/BtGatt.GattService(11998): startScan() - adding client=7
07-07 19:58:48.420: D/BtGatt.btif(11998): btif_gattc_scan
07-07 19:58:48.420: D/BtGatt.btif(11998): btgattc_handle_event: Event 1002
07-07 19:58:48.420: I/IBeaconService(4630): Adjusted scanStopTime to be Mon Jul 07 19:58:49 GMT-04:30 2014
07-07 19:58:48.570: D/dalvikvm(20228): GC_EXPLICIT freed 2477K, 19% free 28473K/35068K, paused 2ms+7ms, total 41ms
07-07 19:58:48.831: D/dalvikvm(592): GC_EXPLICIT freed 523K, 22% free 26548K/33668K, paused 7ms+9ms, total 150ms
07-07 19:58:49.031: D/dalvikvm(21666): GC_EXPLICIT freed 257K, 7% free 9474K/10172K, paused 2ms+4ms, total 23ms
07-07 19:58:49.521: D/Callback(4630): attempting callback via intent: ComponentInfo{com.core.vordrawer/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
...
在最后的 LogCat 中,我相信有用的消息可能是:
I/IBeaconService(4630):将 scanStopTime 调整为 Mon Jul 07 19:58:49 GMT-04:30 2014
D/Callback(4630):尝试通过意图回调:ComponentInfo{com.core.vordrawer/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
但是我不知道该怎么办...
在此先感谢您能给我的任何帮助。