Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android蓝牙可以';无法使用createRfcommSocketServiceRecord进行连接_Android_Sockets_Bluetooth_Connection - Fatal编程技术网

Android蓝牙可以';无法使用createRfcommSocketServiceRecord进行连接

Android蓝牙可以';无法使用createRfcommSocketServiceRecord进行连接,android,sockets,bluetooth,connection,Android,Sockets,Bluetooth,Connection,我已经在安卓2.3.3版本中使用了这种方法,但现在我正在使用另一台2.2版本的设备进行测试。。 我可以使用discovery找到许多设备,但无法通过以下方式连接到其他设备: BluetoothSocket socket = deviceToConnect.createRfcommSocketToServiceRecord(UUID.fromString(MY_UUID)); 另一方面,我使用适当的线程来接受连接,使用: mBluetoothAdapter.cancelDiscovery();

我已经在安卓2.3.3版本中使用了这种方法,但现在我正在使用另一台2.2版本的设备进行测试。。 我可以使用discovery找到许多设备,但无法通过以下方式连接到其他设备:

BluetoothSocket socket = deviceToConnect.createRfcommSocketToServiceRecord(UUID.fromString(MY_UUID));
另一方面,我使用适当的线程来接受连接,使用:

mBluetoothAdapter.cancelDiscovery();


    BluetoothServerSocket ss;
    try {

        ss = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(MainPage.SD_FolderName, UUID.fromString(MY_UUID));
        new Thread(new ListenerHandler(ss, this, resultCode)).start();

    } catch (IOException e) {
        Toast.makeText(this, "There was a problem opening the bluetooth server socket!", Toast.LENGTH_LONG).show();
        finish();
    }
然后在ListenerHandler上,我有以下内容:

BluetoothSocket clientSocket = ss.accept();
但这种联系从未建立过,有什么想法吗?
提前谢谢

请发布您的logcat输出。我无法在虚拟设备上测试,因为没有蓝牙。如何在手机上获得logcat输出?谢谢你的回复!但现在我正在使用另一台2.2版本的设备进行测试。。安卓2.2版意味着什么?我无法使用createRfcommSocketToServiceRecord,无法连接到设备。。。我使用的是线程,问题是连接没有连接