Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.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中的另一个蓝牙设备_Android_Bluetooth_Bluetooth Socket - Fatal编程技术网

使用蓝牙套接字以编程方式将文本发送到android中的另一个蓝牙设备

使用蓝牙套接字以编程方式将文本发送到android中的另一个蓝牙设备,android,bluetooth,bluetooth-socket,Android,Bluetooth,Bluetooth Socket,对于以编程方式将数据发送到另一个蓝牙设备,我 使用蓝牙套接字代码。每当我打电话时 bluetoothSocket.connect();它给出连接被拒绝或连接被拒绝 以对等例外。 我还有一个困惑,我必须在其中使用哪个UUId,或者从哪里获得它 谢谢你的帮助 您可以在此处共享您的异常日志。通过上面的链接查看此链接现在我收到异常“连接被拒绝”我与另一个设备配对或未配对(在调用bluetoothSocket.connect()时为未配对的情况下;它显示配对对话框,但当我单击配对时,它给出“连接被拒绝”例

对于以编程方式将数据发送到另一个蓝牙设备,我 使用蓝牙套接字代码。每当我打电话时 bluetoothSocket.connect();它给出连接被拒绝或连接被拒绝 以对等例外。 我还有一个困惑,我必须在其中使用哪个UUId,或者从哪里获得它


谢谢你的帮助

您可以在此处共享您的异常日志。通过上面的链接查看此链接现在我收到异常“连接被拒绝”我与另一个设备配对或未配对(在调用bluetoothSocket.connect()时为未配对的情况下;它显示配对对话框,但当我单击配对时,它给出“连接被拒绝”例外。所以直到现在都没有运气。。!!
public void openBT() {
        UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Standard
                                                                                // SerialPortService

        try {

            mmSocket = mmDevice.createInsecureRfcommSocketToServiceRecord(uuid);
            Method m = mmDevice.getClass().getMethod("createInsecureRfcommSocket", new Class[] {int.class});
            mmSocket = (BluetoothSocket) m.invoke(mmDevice, 3);
            mBluetoothAdapter.cancelDiscovery();
            mmSocket.connect();
            /*mmSocket = mmDevice.createRfcommSocketToServiceRecord(uuid);

            mmSocket.connect();*/
            mmOutputStream = mmSocket.getOutputStream();
            mmInputStream = mmSocket.getInputStream();

            beginListenForData();

            myLabel.setText("Bluetooth Opened");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }