相关疑难解决方法(0)

接受线程的IOException

我的应用程序的一部分通过蓝牙连接到设备,通常工作正常但偶尔它不会连接,我得到以下错误

03-11 10:29:20.328: E/BluetoothComService(8059): accept() failed
03-11 10:29:20.328: E/BluetoothComService(8059): java.io.IOException: Operation Canceled
03-11 10:29:20.328: E/BluetoothComService(8059):    at android.bluetooth.BluetoothSocket.acceptNative(Native Method)
03-11 10:29:20.328: E/BluetoothComService(8059):    at android.bluetooth.BluetoothSocket.accept(BluetoothSocket.java:316)
03-11 10:29:20.328: E/BluetoothComService(8059):    at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:105)
03-11 10:29:20.328: E/BluetoothComService(8059):    at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:91)
03-11 10:29:20.328: E/BluetoothComService(8059):    at com.mypackage.name.bluetooth.BluetoothService$AcceptThread.run(BluetoothService.java:298)
Run Code Online (Sandbox Code Playgroud)

这是我得到例外的那一行

socket = mmServerSocket.accept();    
Run Code Online (Sandbox Code Playgroud)

这是完整的AcceptThread

private class AcceptThread extends Thread {
    // The local server socket
    private BluetoothServerSocket mmServerSocket;
    public boolean successInit = false;

    public AcceptThread() {
        closeAllConnections();

        /*
         * if(mmServerSocket != null) { try { mmServerSocket.close(); } catch
         * (IOException e) …
Run Code Online (Sandbox Code Playgroud)

android bluetooth ioexception iobluetooth

7
推荐指数
1
解决办法
5878
查看次数

标签 统计

android ×1

bluetooth ×1

iobluetooth ×1

ioexception ×1