错误日志如下:
2019-03-24 11:27:21.015 19332-19332/com.wmailn.blepen E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wmailn.blepen, PID: 19332
java.lang.RuntimeException: Unable to resume activity {com.wmailn.blepen/com.wmailn.blepen.ui.pen.MyPenActivity_}: java.lang.IllegalArgumentException: null is not a valid Bluetooth address
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4290)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4330)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:7470)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
Caused by: java.lang.IllegalArgumentException: null is not a valid Bluetooth address
at android.os.Parcel.createException(Parcel.java:1957)
at android.os.Parcel.readException(Parcel.java:1921)
at android.os.Parcel.readException(Parcel.java:1871)
at android.bluetooth.IBluetooth$Stub$Proxy.getRemoteName(IBluetooth.java:1558)
at android.bluetooth.BluetoothDevice.getName(BluetoothDevice.java:860)
at com.vise.baseble.model.BluetoothLeDevice.getName(BluetoothLeDevice.java:264)
at com.vise.baseble.core.DeviceMirrorPool.isContainDevice(DeviceMirrorPool.java:108)
at com.vise.baseble.ViseBle.isConnect(ViseBle.java:240)
at com.wmailn.blepen.utils.PenUtils.isConnecting(PenUtils.java:56)
at com.wmailn.blepen.ui.pen.MyPenActivity.onResume(MyPenActivity.java:113)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
at android.app.Activity.performResume(Activity.java:7592)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4272)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4330)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:7470)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
连接成功后,获取连接状态方法报错
方法调用如下: ViseBle.getInstance().isConnect(pen.device) 或者: ViseBle.getInstance().getConnectState(pen.device).equals(ConnectState.CONNECT_SUCCESS) 两个方法均报错
连接成功后打印的日志如下: DeviceMirror{bluetoothLeDevice=BluetoothLeDevice [mDevice=05:11:07:B1:17:11, mRssi=-56, mScanRecord=0201061107fb349b5f8000008000100000c8fc00000319001c020a080f09434f4f4c50454e20423131373131000000000000000000000000000000000000, mRecordStore=AdRecordStore [mLocalNameComplete=COOLPEN B11711, mLocalNameShort=], getBluetoothDeviceBondState()=UnBonded, getBluetoothDeviceClassName()=Unknown, Unknown (class=7936)], uniqueSymbol='05:11:07:B1:17:11COOLPEN B11711'} Device is:BluetoothLeDevice [mDevice=05:11:07:B1:17:11, mRssi=-56, mScanRecord=0201061107fb349b5f8000008000100000c8fc00000319001c020a080f09434f4f4c50454e20423131373131000000000000000000000000000000000000, mRecordStore=AdRecordStore [mLocalNameComplete=COOLPEN B11711, mLocalNameShort=], getBluetoothDeviceBondState()=UnBonded, getBluetoothDeviceClassName()=Unknown, Unknown (class=7936)] Device Name is:COOLPEN B11711 Device Address is:05:11:07:B1:17:11
错误日志如下: 2019-03-24 11:27:21.015 19332-19332/com.wmailn.blepen E/AndroidRuntime: FATAL EXCEPTION: main Process: com.wmailn.blepen, PID: 19332 java.lang.RuntimeException: Unable to resume activity {com.wmailn.blepen/com.wmailn.blepen.ui.pen.MyPenActivity_}: java.lang.IllegalArgumentException: null is not a valid Bluetooth address at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4290) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4330) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) at android.os.Handler.dispatchMessage(Handler.java:109) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:7470) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958) Caused by: java.lang.IllegalArgumentException: null is not a valid Bluetooth address at android.os.Parcel.createException(Parcel.java:1957) at android.os.Parcel.readException(Parcel.java:1921) at android.os.Parcel.readException(Parcel.java:1871) at android.bluetooth.IBluetooth$Stub$Proxy.getRemoteName(IBluetooth.java:1558) at android.bluetooth.BluetoothDevice.getName(BluetoothDevice.java:860) at com.vise.baseble.model.BluetoothLeDevice.getName(BluetoothLeDevice.java:264) at com.vise.baseble.core.DeviceMirrorPool.isContainDevice(DeviceMirrorPool.java:108) at com.vise.baseble.ViseBle.isConnect(ViseBle.java:240) at com.wmailn.blepen.utils.PenUtils.isConnecting(PenUtils.java:56) at com.wmailn.blepen.ui.pen.MyPenActivity.onResume(MyPenActivity.java:113) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456) at android.app.Activity.performResume(Activity.java:7592) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4272) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4330) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2123) at android.os.Handler.dispatchMessage(Handler.java:109) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:7470) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)