Java android和PC蓝牙应用程序之间的连接
我正在开发一个蓝牙应用程序,其中包括将我的android蓝牙应用程序连接到计算机上运行的服务器。该服务器也是使用blue cove api制作的蓝牙应用程序 我现在面临的问题是,我无法在我的移动应用程序和计算机服务器应用程序之间建立连接 以下是我的android应用程序代码: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
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 我已经在我的博客上发布了我的示例,包括客户端和服务器 希望这有帮助