Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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
Java android和PC蓝牙应用程序之间的连接_Java_Android_Bluetooth - Fatal编程技术网

Java android和PC蓝牙应用程序之间的连接

Java android和PC蓝牙应用程序之间的连接,java,android,bluetooth,Java,Android,Bluetooth,我正在开发一个蓝牙应用程序,其中包括将我的android蓝牙应用程序连接到计算机上运行的服务器。该服务器也是使用blue cove api制作的蓝牙应用程序 我现在面临的问题是,我无法在我的移动应用程序和计算机服务器应用程序之间建立连接 以下是我的android应用程序代码: try { // Connect the device through the socket. This will block // until it succeeds o

我正在开发一个蓝牙应用程序,其中包括将我的android蓝牙应用程序连接到计算机上运行的服务器。该服务器也是使用blue cove api制作的蓝牙应用程序

我现在面临的问题是,我无法在我的移动应用程序和计算机服务器应用程序之间建立连接

以下是我的android应用程序代码:

 try {
            // Connect the device through the socket. This will block
            // until it succeeds or throws an exception
            mySocket = myDevice.createRfcommSocketToServiceRecord(MY_UUID);
            mySocket.connect();
            toast = Toast.makeText(context, "Connection established",   thisClass.duration);
            toast.show();
          } catch (IOException connectException) {
            // Unable to connect; close the socket and get out
            try {
                mySocket.close();
                toast = Toast.makeText(context, "Connection not established", thisClass.duration);
                toast.show();
            } catch (IOException closeException) { }
            return;
        }

问题在哪里,或者我可能遗漏了什么。我对socket.connect()方法的理解也有歧义。请在这方面帮助我

我刚刚完成一个类似的应用程序的工作,在连接上遇到了问题。多看一点代码会有帮助,但上面的摘录看起来像我下面的示例。首先,我会检查您尝试连接的PC上是否存在MY_UUID

我已经在我的博客上发布了我的示例,包括客户端和服务器

希望这有帮助