Android蓝牙.connect()异常Nexus 7 OBDII适配器

use*_*880 5 android bluetooth connect ioexception obd-ii

我正在使用标准API程序连接到设备.特别是OBDII蓝牙适配器.

我有两个不同型号的OBDII蓝牙适配器.运行完全相同的代码,第一个将与我测试的每个手机/平板电脑配对和连接没有问题.第二个将配对和连接正常,除了我的运行Android 4.2的Nexus 7

它抛出一个IOexception: read failed, socket might closed or timeout, read ret: -1

认为这只是设备本身或更新版本的错误...但是另一个软件"扭矩"能够从我的Nexus 7连接到任一适配器.

所以我显然做了一些错误/不同的事情,这只是后来的OS中的一个问题???

任何帮助搞清楚这一点将不胜感激.

    public void run() {
        Log.i(TAG, "BEGIN mConnectThread");
        setName("ConnectThread");

        // Always cancel discovery because it will slow down a connection
        mAdapter.cancelDiscovery();

        // Make a connection to the BluetoothSocket
        try {
            // This is a blocking call and will only return on a
            // successful connection or an exception

            mmSocket.connect(); <=**This is where the exception is thrown

        } catch (IOException e) {
            Etype =  "Connection to: " + mmDevice.getName() + " at: "
                    + mmDevice.getAddress() + " failed: " + e.getMessage();
            connectionFailed();
            // Close the socket
            try {
                mmSocket.close();
            } catch (IOException e2) {
                Log.e(TAG, "unable to close() socket during connection failure", e2);
            }
            // Start the service over to restart listening mode
            BluetoothChatService.this.start();
            return;
        }
Run Code Online (Sandbox Code Playgroud)

mat*_*hes 0

我知道这是一个老问题了。但由于我无法在网上找到任何解决方案。搜索此内容的人可能对我发现的解决方法感兴趣:IOException:读取失败,套接字可能关闭 - Android 4.3 上的蓝牙