Android java.io.IOException:[JSR82]接受:未创建连接(失败或中止)

Android java.io.IOException:[JSR82]接受:未创建连接(失败或中止),android,bluetooth,Android,Bluetooth,我想在三星GALAXY TAB 8.9中创建BluetoothServerSocket。(安卓4.04) 调用mmServerSocket.accept()时-throwed: “java.io.IOException:[JSR82]接受:未创建连接(失败或中止)。” 我读了很多类似的文章,但没有详细的答案。 也许有人解决了类似的问题,或者知道这个异常意味着什么 谢谢 从“ChatExample”获取的代码: public class AcceptThread extends Thr

我想在三星GALAXY TAB 8.9中创建BluetoothServerSocket。(安卓4.04) 调用mmServerSocket.accept()时-throwed:

“java.io.IOException:[JSR82]接受:未创建连接(失败或中止)。” 我读了很多类似的文章,但没有详细的答案。 也许有人解决了类似的问题,或者知道这个异常意味着什么

谢谢 从“ChatExample”获取的代码:

     public  class AcceptThread extends Thread {
    // The local server socket
    private final BluetoothServerSocket mmServerSocket;
    private String mSocketType;

    public AcceptThread(boolean secure) {            BluetoothServerSocket tmp = null;
        mSocketType = secure ? "Secure" : "Insecure";

        try {
                tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                        NAME_INSECURE, MY_UUID_INSECURE);

        } catch (IOException e) {
            Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
        }
        mmServerSocket = tmp;
    }

    public void run() {
        if (D) Log.d(TAG, "Socket Type: " + mSocketType +
                "BEGIN mAcceptThread" + this);
        setName("AcceptThread" + mSocketType);

        BluetoothSocket socket = null;

        // Listen to the server socket if we're not connected
        while (mState != STATE_CONNECTED) {
            try {
                // This is a blocking call and will only return on a
                // successful connection or an exception
               Log.d(TAG, "Socket " + socket + " | ServerSocket " + mmServerSocket);
               socket = mmServerSocket.accept();
               Log.d(TAG, "new accepted Socket with " + socket.getRemoteDevice().getName());

            } catch (IOException e) {
                Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed", e);
            //    BluetoothServiceViaProtobuf.this.start();
                break;
            }

            // If a connection was accepted
            if (socket != null) {
                synchronized (BluetoothServiceViaProtobuf.this) {
                    switch (mState) {
                        case STATE_LISTENING:
                        case STATE_CONNECTING:
                            // Situation normal. Start the connected thread.
                            connected(socket, socket.getRemoteDevice(),
                                    mSocketType);
                            break;
                        case STATE_NONE:
                        case STATE_CONNECTED:
                            // Either not ready or already connected. Terminate new socket.
                            try {
                                socket.close();
                            } catch (IOException e) {
                                Log.e(TAG, "Could not close unwanted socket", e);
                            }
                            break;
                    }
                }
            }
        }
        if (D) Log.i(TAG, "END mAcceptThread, socket Type: " + mSocketType + "  "+ BluetoothServiceViaProtobuf.this.getState());

    }

    public void cancel() {
        if (D) Log.d(TAG, "Socket Type" + mSocketType + "stop " + this );
        try {
           mmServerSocket.close();
        } catch (IOException e) {
            Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
        }
    }
}