一个蓝牙连接服务。就是每过个10秒连接一次已经配对的蓝牙设备。如果连接成功就结束。
但是执行个几十次,就会出现这个问题。然后服务就终止了。
求大大解救。谢谢
12-04 15:58:38.259: D/BluetoothCheckHandler(3019): setState() 2 -> 1
12-04 15:58:38.259: D/BluetoothCheckHandler(3019): 不能连接到蓝牙设备!
12-04 15:58:38.259: D/BluetoothCheckHandler(3019): 启动接收监听
12-04 15:58:38.279: D/BluetoothCheckHandler(3019): setState() 1 -> 1
12-04 15:58:38.289: D/BluetoothCheckHandler(3019): 开始 监听Socket对象Thread[Thread-493,5,main]
12-04 15:58:43.069: I/BluetoothCheckService(3019): 第67次尝试链接[间隔10000毫秒]
12-04 15:58:43.079: I/BluetoothCheckService(3019): 连接蓝牙设备:V-checker
12-04 15:58:43.079: I/BluetoothCheckService(3019): 98:D3:31:30:23:BC
12-04 15:58:43.089: D/BluetoothCheckHandler(3019): 连接到蓝牙设备: 98:D3:31:30:23:BC
12-04 15:58:43.099: D/BluetoothCheckHandler(3019): cancel Thread[AcceptThread,5,main]
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): accept() failed
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): java.io.IOException: Operation Canceled
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): at android.bluetooth.BluetoothSocket.acceptNative(Native Method)
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): at android.bluetooth.BluetoothSocket.accept(BluetoothSocket.java:364)
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:113)
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:99)
12-04 15:58:43.119: E/BluetoothCheckHandler(3019): at com.vchecker.iobd.comm.bluetooth.BluetoothCheckHandler$AcceptThread.run(BluetoothCheckHandler.java:380)
12-04 15:58:43.129: D/BluetoothCheckHandler(3019): setState() 1 -> 2
12-04 15:58:43.129: I/BluetoothCheckHandler(3019): 开始 连接蓝牙线程
12-04 15:58:43.149: I/BluetoothCheckHandler(3019): END mAcceptThread
12-04 15:58:48.309: E/BluetoothCheckHandler(3019): unable to connect() socket
12-04 15:58:48.309: E/BluetoothCheckHandler(3019): java.io.IOException: Host is down
12-04 15:58:48.309: E/BluetoothCheckHandler(3019): at android.bluetooth.BluetoothSocket.connectNative(Native Method)
12-04 15:58:48.309: E/BluetoothCheckHandler(3019): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:233)
12-04 15:58:48.309: E/BluetoothCheckHandler(3019): at com.vchecker.iobd.comm.bluetooth.BluetoothCheckHandler$ConnectThread.run(BluetoothCheckHandler.java:464)
12-04 15:58:48.319: D/BluetoothCheckHandler(3019): setState() 2 -> 1
12-04 15:58:48.319: D/BluetoothCheckHandler(3019): 不能连接到蓝牙设备!
12-04 15:58:48.319: D/BluetoothCheckHandler(3019): 启动接收监听
12-04 15:58:48.339: D/BluetoothCheckHandler(3019): setState() 1 -> 1
12-04 15:58:48.339: D/BluetoothCheckHandler(3019): 开始 监听Socket对象Thread[Thread-495,5,main]
12-04 15:59:15.119: D/ActivityThread(4353): setTargetHeapIdealFree:8388608
12-04 15:59:15.119: D/ActivityThread(4353): setTargetHeapConcurrentStart:2097152
12-04 15:59:15.229: E/AdFireWallNative(4353): AdFrieWall JNI_OnLoad
12-04 15:59:15.229: E/AdFireWallNative(4353): AdFireWall JNI_OnLoad done.
12-04 15:59:15.249: I/BluetoothCheckService(4353): onCreate()...
12-04 15:59:15.259: I/BluetoothCheckService(4353): onStart()...
------解决思路----------------------
在模拟器里 测试也会退出吗?
------解决思路----------------------
试试GenyMotion, 支持蓝牙4.0.