Android蓝牙java.io.IOException:连接被拒绝

时间:2013-04-11 13:18:04

标签: java android sockets exception bluetooth

我的android套接字有问题。我正在将PC上的USB加密狗连接到Android手机,即三星Galaxy Note II。我正在使用标准蓝牙套接字创建带有createRfcommSocketToServiceRecord的套接字。

btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);

服务器正在侦听listenUsingRfcommWithServiceRecord。

tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,MY_UUID);

客户端和服务器之间的配对很好。我试过将PC作为服务器而手机就是客户端,反之亦然。在这两种情况下,我都得到相同的例外。 logcat粘贴在下面。

04-12 06:14:58.229: D/THINBTCLIENT(2613): ON CREATE got remote device6C:F3:73:47:5B:39

04-12 06:14:58.229: D/THINBTCLIENT(2613): ON CREATE Socket created.

04-12 06:15:01.229: E/THINBTCLIENT(2613): socket connect threw an exception.

04-12 06:15:01.229: E/THINBTCLIENT(2613): java.io.IOException: Connection refused

04-12 06:15:01.229: E/THINBTCLIENT(2613):   at android.bluetooth.BluetoothSocket.connectNative(Native Method)

04-12 06:15:01.229: E/THINBTCLIENT(2613):   at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:204)

04-12 06:15:01.229: E/THINBTCLIENT(2613):   at com.example.myfirstapp.taskScreen$7.onClick(taskScreen.java:245)

我用谷歌搜索,有人说不配对和配对再次有帮助。我也尝试过,但仍然存在异常。如果有人有任何想法,我们将非常感激。

0 个答案:

没有答案
相关问题