English 中文(简体)
Android IOException坏案卷
原标题:Android Bluetooth IOException bad file number

我听到了“蓝色素”电话的听觉。 这一read子将遭到另一只read子的杀害和重新启用。 当它收到杀人信号时,它关闭了蓝色ServerSocket,从而导致接受的IOException,并摆脱了无限的lo。 但有时,在这些开端和重新启用听众UsingRfcommWithserviceRecord(电话)时,将收集一个“坏账号”的IOException,并过早地撤出。 我认为,在杀人时,我可能不会正确地关闭BT部分,而只是说什么还没有。 难道有人会给我一些要点?

private class ReceiveThread extends Thread {
    private final static String TAG = "ReceiveThread";
    private BluetoothServerSocket mmBtServer;
    private BluetoothSocket mmBtSocket;

    public ReceiveThread() {
        setName(TAG);
    }

    public void run() {
        if(D) Log.d(TAG,"RceiveThread running");

        while(true) {
            try {
                SetState(SERVICE_STATE.LISTENING);
                mmBtServer = mBtAdapter.listenUsingRfcommWithServiceRecord(mAppName, mUUID);

                if(D) Log.d(TAG,"ReceiveThd accepting connection");
                mmBtSocket = mmBtServer.accept();
                // Close server once socket establishes
                mmBtServer.close();

                if(D) Log.d(TAG, "Connection Established");
                SetState(SERVICE_STATE.CONNECTED_BUSY);



                /** Handle Processing **/



                // Close socket
                mmBtSocket.close();
            } catch (IOException e) {
                SetState(SERVICE_STATE.NOT_CONNECTED);
                Log.d(TAG,"IOException in ReceiveThread", e);
                break;
            }

            SetState(SERVICE_STATE.CONNECTED_IDLE);
        }
    }

    public void kill() {
        try {
            if(mmBtSocket!=null) mmBtSocket.close();
            if(mmBtServer!=null) mmBtServer.close();
        } catch (IOException e) {
            Log.d(TAG,"Failure killing ReceiveThread", e);
        }
        SetState(SERVICE_STATE.NOT_CONNECTED);
    }
}
最佳回答

如果有人感兴趣的话。 我发现,这只是在某些电话上发生的。 在大约20-30个停机和起步周期之后,我可以始终在我的三星银河S上照搬。 我也经常从蓝z那里收集“记忆”,导致我感到问题在于一旁。 我不能在Droid X、HTC G2或我的Touch 4G上照搬。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签