2012-05-03 117 views
4

我正在研究蓝牙应用程序,其中涉及我的android蓝牙应用程序与在计算机上运行的服务器的连接。该服务器也是使用蓝湾API制作的蓝牙应用程序。Android和PC蓝牙应用程序之间的连接

我现在面临的问题是我无法连接我的移动应用程序和该计算机服务器应用程序。

这里是我的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()方法的理解也有歧义。请在这方面帮助我。

回答