FastBle icon indicating copy to clipboard operation
FastBle copied to clipboard

sending message to a Handler on a dead thread

Open sumeet-mibo opened this issue 4 years ago • 1 comments

I am getting this exception when writing data

2020-04-07 09:47:57.973 7322-7322/... W/MessageQueue: Handler (SplitWriter$1) {b1946c5} sending message to a Handler on a dead thread
    java.lang.IllegalStateException: Handler (SplitWriter$1) {b1946c5} sending message to a Handler on a dead thread
        at android.os.MessageQueue.enqueueMessage(MessageQueue.java:555)
        at android.os.Handler.enqueueMessage(Handler.java:728)
        at android.os.Handler.sendMessageAtTime(Handler.java:620)
        at android.os.Handler.sendMessageDelayed(Handler.java:590)
        at com.clj.fastble.scan.bluetooth.SplitWriter$2.onWriteSuccess(SplitWriter.java:100)
        at com.clj.fastble.scan.bluetooth.BleConnector$1.handleMessage(BleConnector.java:134)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:203)
        at android.app.ActivityThread.main(ActivityThread.java:6293)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)

sumeet-mibo avatar Apr 07 '20 06:04 sumeet-mibo

为什么不试试 intentservice 来处理所有的连接,然后 保存订阅的实例到application, 配合 eventbus , 哦豁,起飞

Why not try intentservice to handle all connections, and then

Save the subscription instance to the application,

With eventbus,

Oh, whoa, take off


如果你这么做的话,你要注意eventbus在activity和intentservice中eventbus订阅的的浸泡和脱水,然后在自己的结束周期停止服务

If you do this, you should pay attention to the soaking and dehydration of eventbus subscription in activity and intentservice, and then stop the service in its own end cycle

kingiis avatar Apr 09 '20 08:04 kingiis