gpt4 book ai didi

java - Android BLE 无法正确连接到设备

转载 作者:太空宇宙 更新时间:2023-11-04 11:31:30 25 4
gpt4 key购买 nike

首先介绍一些背景知识,我正在使用 RedBear Blend 微 Controller 尝试通过 BLE 将数据发送到一个大学项目的 Android 应用程序中,该项目使用一些开源血糖仪硬件,并尝试将其变成带有配套应用程序的“智能”设备来记录数据。

使用此处提供的示例 RedBear 聊天应用程序时效果很好:https://github.com/RedBearLab/Android/tree/master/Examples/Chat

示例应用程序中的 Logcat:

5-01 12:39:26.316 2753-2753/com.redbear.chat W/System: ClassLoader referenced unknown path: /data/app/com.redbear.chat-1/lib/arm
05-01 12:39:26.406 2753-2753/com.redbear.chat D/SecWifiDisplayUtil: Metadata value : none
05-01 12:39:26.406 2753-2753/com.redbear.chat D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{6a1bff8 I.E...... R.....ID 0,0-0,0}
05-01 12:39:26.406 2753-2861/com.redbear.chat D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-01 12:39:26.456 2753-2861/com.redbear.chat I/Adreno: QUALCOMM build : d842ad3, Ia10634f51b
Build Date : 01/04/16
OpenGL ES Shader Compiler Version: XE031.06.00.05
Local Branch : mybranch17578993
Remote Branch : quic/LA.BF.2.1.2_rb1.7
Remote Branch : NONE
Reconstruct Branch : NOTHING
05-01 12:39:26.456 2753-2861/com.redbear.chat D/libEGL: eglInitialize EGLDisplay = 0xae1e87c4
05-01 12:39:26.456 2753-2861/com.redbear.chat I/OpenGLRenderer: Initialized EGL, version 1.4
05-01 12:39:26.486 2753-2753/com.redbear.chat D/BluetoothGatt: connect() - device: F0:44:62:58:BB:ED, auto: false
05-01 12:39:26.486 2753-2753/com.redbear.chat D/BluetoothGatt: registerApp()
05-01 12:39:26.486 2753-2753/com.redbear.chat D/BluetoothGatt: registerApp() - UUID=345487dc-e3ef-4a26-866c-b504f43c14c3
05-01 12:39:26.526 2753-2753/com.redbear.chat D/RBLService: Trying to create a new connection.
05-01 12:39:26.526 2753-2769/com.redbear.chat D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
05-01 12:39:26.536 2753-2753/com.redbear.chat W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 12:39:26.536 2753-2753/com.redbear.chat W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 12:39:26.546 2753-2861/com.redbear.chat D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.redbear.chat
05-01 12:39:26.576 2753-2861/com.redbear.chat V/RenderScript: 0x9e09e000 Launching thread(s), CPUs 4
05-01 12:39:26.586 2753-2753/com.redbear.chat D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
05-01 12:39:26.606 2753-2753/com.redbear.chat I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@ca8aa6a time:49435618
05-01 12:39:26.726 2753-2753/com.redbear.chat D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 96 - 0, 996) vi=Rect(0, 96 - 0, 996) or=1
05-01 12:39:28.976 2753-2809/com.redbear.chat D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=F0:44:62:58:BB:ED
05-01 12:39:28.986 2753-2809/com.redbear.chat I/RBLService: Connected to GATT server.
05-01 12:39:28.996 2753-2809/com.redbear.chat D/BluetoothGatt: discoverServices() - device: F0:44:62:58:BB:ED
05-01 12:39:28.996 2753-2809/com.redbear.chat I/RBLService: Attempting to start service discovery:true
05-01 12:39:29.276 2753-2768/com.redbear.chat D/BluetoothGatt: onClientConnParamsChanged() - Device=F0:44:62:58:BB:ED interval=6 status=0
05-01 12:39:29.536 2753-2768/com.redbear.chat D/BluetoothGatt: onSearchComplete() = Device=F0:44:62:58:BB:ED Status=0
05-01 12:39:29.536 2753-2753/com.redbear.chat D/BluetoothGatt: setCharacteristicNotification() - uuid: 713d0002-503e-4c75-ba94-3148f18d941e enable: true
05-01 12:39:29.566 2753-2809/com.redbear.chat D/BluetoothGatt: onClientConnParamsChanged() - Device=F0:44:62:58:BB:ED interval=39 status=0
05-01 12:39:34.846 2753-2769/com.redbear.chat D/BluetoothGatt: onClientConnParamsChanged() - Device=F0:44:62:58:BB:ED interval=18 status=0
05-01 12:40:25.866 2753-2753/com.redbear.chat V/ActivityThread: updateVisibility : ActivityRecord{f85a5ca token=android.os.BinderProxy@ca8aa6a {com.redbear.chat/com.redbear.chat.Chat}} show : true
05-01 12:40:31.266 2753-2753/com.redbear.chat D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 1092) vi=Rect(0, 96 - 0, 1092) or=1
05-01 12:40:31.296 2753-2753/com.redbear.chat D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1

但是,当我尝试将功能移植到我的应用程序中时,它们似乎没有正确连接,因为我没有得到相同的输出到 logcat,相反,由于连接尚未正确初始化,应用程序因空指针异常而崩溃。所以我不确定为了让设备成功连接我做错了什么。

我尝试将示例中的功能移植到以下文件中的应用程序中:

MainActivity.java
Device.java
StoreReading.java
TakeReading.java

该应用程序位于我的 github 上。 https://github.com/rowmanns/android_ble/tree/master/BloodGlucoseV3

05-01 13:03:57.606 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{1186991 I.E...... R.....ID 0,0-0,0}
05-01 13:03:57.616 25495-25645/com.fyp.rowan.bloodglucosev3 D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-01 13:03:57.646 25495-25645/com.fyp.rowan.bloodglucosev3 I/Adreno: QUALCOMM build : d842ad3, Ia10634f51b
Build Date : 01/04/16
OpenGL ES Shader Compiler Version: XE031.06.00.05
Local Branch : mybranch17578993
Remote Branch : quic/LA.BF.2.1.2_rb1.7
Remote Branch : NONE
Reconstruct Branch : NOTHING
05-01 13:03:57.646 25495-25645/com.fyp.rowan.bloodglucosev3 D/libEGL: eglInitialize EGLDisplay = 0x9f7ff7c4
05-01 13:03:57.646 25495-25645/com.fyp.rowan.bloodglucosev3 I/OpenGLRenderer: Initialized EGL, version 1.4
05-01 13:03:57.676 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
05-01 13:03:57.686 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:03:57.686 25495-25645/com.fyp.rowan.bloodglucosev3 D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.fyp.rowan.bloodglucosev3
05-01 13:03:57.716 25495-25495/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@49e44d2 time:50906726
05-01 13:04:00.116 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: ViewPostImeInputStage processPointer 0
05-01 13:04:00.206 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: ViewPostImeInputStage processPointer 1
05-01 13:04:00.216 25495-25495/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_launch_request id:com.fyp.rowan.bloodglucosev3 time:50909220
05-01 13:04:00.266 25495-25495/com.fyp.rowan.bloodglucosev3 I/ToolbarWidgetWrapper: Progress display unsupported
05-01 13:04:00.286 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: startLeScan(): null
05-01 13:04:00.286 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:00.286 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:00.286 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothLeScanner: Start Scan
05-01 13:04:00.286 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:00.296 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:00.296 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:00.296 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:00.306 25495-25495/com.fyp.rowan.bloodglucosev3 D/SecWifiDisplayUtil: Metadata value : none
05-01 13:04:00.316 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{948186d V.E...... R.....I. 0,0-0,0}
05-01 13:04:00.326 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{358dc4c I.E...... R.....ID 0,0-0,0}
05-01 13:04:00.336 25495-25583/com.fyp.rowan.bloodglucosev3 D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
05-01 13:04:00.406 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
05-01 13:04:00.406 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:00.426 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.426 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:00.436 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
05-01 13:04:00.466 25495-25645/com.fyp.rowan.bloodglucosev3 D/OpenGLRenderer: endAllActiveAnimators on 0xb2b49680 (RippleDrawable) with handle 0xa91ee510
05-01 13:04:00.466 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.476 25495-25495/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@bac547f time:50909481
05-01 13:04:00.526 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.576 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.626 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.686 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.726 25495-25495/com.fyp.rowan.bloodglucosev3 V/ActivityThread: updateVisibility : ActivityRecord{c3a515a token=android.os.BinderProxy@49e44d2 {com.fyp.rowan.bloodglucosev3/com.fyp.rowan.bloodglucosev3.MainActivity}} show : false
05-01 13:04:00.746 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.846 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.896 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:00.956 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.016 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.076 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.136 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.196 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.276 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.326 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.366 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.416 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.476 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.536 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.586 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.646 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.696 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.746 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.806 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.866 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.926 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:01.966 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.026 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.146 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.206 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.266 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.316 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.376 25495-25588/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.436 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.486 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.546 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.606 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.646 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.696 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.756 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.816 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.876 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.926 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:02.986 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.046 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.106 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.166 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.216 25495-25507/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.286 25495-25506/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.326 25495-25733/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_launch_request id:com.fyp.rowan.bloodglucosev3 time:50912335
05-01 13:04:03.336 25495-25583/com.fyp.rowan.bloodglucosev3 D/ScanRecord: parseFromBytes
05-01 13:04:03.346 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: stopLeScan()
05-01 13:04:03.346 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:03.346 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:03.346 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:03.356 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothAdapter: STATE_ON
05-01 13:04:03.356 25495-25731/com.fyp.rowan.bloodglucosev3 D/BluetoothLeScanner: Stop Scan
05-01 13:04:03.396 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #3 mView = null
05-01 13:04:03.406 25495-25495/com.fyp.rowan.bloodglucosev3 E/ViewRootImpl: sendUserActionEvent() mView == null
05-01 13:04:03.426 25495-25495/com.fyp.rowan.bloodglucosev3 D/AbsListView: Get MotionRecognitionManager
05-01 13:04:03.426 25495-25495/com.fyp.rowan.bloodglucosev3 E/MotionRecognitionManager: mSContextService = android.hardware.scontext.ISContextService$Stub$Proxy@35944f3
05-01 13:04:03.436 25495-25495/com.fyp.rowan.bloodglucosev3 E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@393d4f
05-01 13:04:03.436 25495-25495/com.fyp.rowan.bloodglucosev3 E/MotionRecognitionManager: motionService = com.samsung.android.motion.IMotionRecognitionService$Stub$Proxy@393d4f
05-01 13:04:03.436 25495-25495/com.fyp.rowan.bloodglucosev3 D/SecWifiDisplayUtil: Metadata value : none
05-01 13:04:03.436 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{1765f6b I.E...... R.....ID 0,0-0,0}
05-01 13:04:03.486 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:03.496 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
05-01 13:04:03.536 25495-25495/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@81584ba time:50912545
05-01 13:04:03.756 25495-25495/com.fyp.rowan.bloodglucosev3 V/ActivityThread: updateVisibility : ActivityRecord{fbc0c5e token=android.os.BinderProxy@bac547f {com.fyp.rowan.bloodglucosev3/com.fyp.rowan.bloodglucosev3.TakeReading}} show : false
05-01 13:04:04.976 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: ViewPostImeInputStage processPointer 0
05-01 13:04:05.076 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: ViewPostImeInputStage processPointer 1
05-01 13:04:05.156 25495-25495/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_launch_request id:com.fyp.rowan.bloodglucosev3 time:50914163
05-01 13:04:05.236 25495-25495/com.fyp.rowan.bloodglucosev3 D/SecWifiDisplayUtil: Metadata value : none
05-01 13:04:05.236 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{5f5d546 I.E...... R.....ID 0,0-0,0}
05-01 13:04:05.296 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:05.296 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:05.316 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
05-01 13:04:05.336 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:05.356 25495-25645/com.fyp.rowan.bloodglucosev3 D/OpenGLRenderer: endAllActiveAnimators on 0x9b0cc680 (ListView) with handle 0x9d855ee0
05-01 13:04:05.356 25495-25495/com.fyp.rowan.bloodglucosev3 I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@3d1f88 time:50914367
05-01 13:04:05.496 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 96 - 0, 996) vi=Rect(0, 96 - 0, 996) or=1
05-01 13:04:05.586 25495-25495/com.fyp.rowan.bloodglucosev3 W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
05-01 13:04:05.606 25495-25495/com.fyp.rowan.bloodglucosev3 D/ViewRootImpl: #3 mView = null
05-01 13:04:16.176 25495-25495/com.fyp.rowan.bloodglucosev3 D/AndroidRuntime: Shutting down VM
05-01 13:04:16.186 25495-25495/com.fyp.rowan.bloodglucosev3 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fyp.rowan.bloodglucosev3, PID: 25495
java.lang.RuntimeException: Unable to destroy activity {com.fyp.rowan.bloodglucosev3/com.fyp.rowan.bloodglucosev3.StoreReading}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.fyp.rowan.bloodglucosev3.RBLService.disconnect()' on a null object reference
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5062)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5085)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5348)
at android.app.ActivityThread.access$1200(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1800)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.fyp.rowan.bloodglucosev3.RBLService.disconnect()' on a null object reference
at com.fyp.rowan.bloodglucosev3.StoreReading.onDestroy(StoreReading.java:155)
at android.app.Activity.performDestroy(Activity.java:7102)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1170)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5040)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5085) 
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5348) 
at android.app.ActivityThread.access$1200(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1800) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7225) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

任何帮助/想法将不胜感激!

最佳答案

因此,在一些帮助下,我今天找出了导致此问题的原因。

事实证明,bindService() 默默地失败了。

bindService(new Intent(this, RBLService.class), mServiceConnection, BIND_AUTO_CREATE);

这是因为我没有在 list 文件中列出 RBLService。 (我的一个简单的新手错误......)

一旦此服务在 list 文件中列出,它就会按预期工作。

service
android:name="com.fyp.rowan.bloodglucosev3.RBLService"
android:enabled="true" />

关于java - Android BLE 无法正确连接到设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43719385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com