Android Bluetooth socket freeze application

后端 未结 6 2384
南旧
南旧 2021-02-14 23:46

I have a strange issue with bluetooth socket. If I create socket and later close application, android device freeze with very hight CPU load.

Here my sample code:

<
6条回答
  •  庸人自扰
    2021-02-15 00:10

    Take a look at the code that calls cancel(). In particular, look at how it handles runtime exceptions thrown by cancel(). The code above will throw a NPE if cancel() is called after ConnectThread() catches an exception.

    Also, check any loops where you perform an operation on socket. Once the close() is called, connect(), getInputStream(), and getOutputStream() will throw IOEs.

提交回复
热议问题