在Android 2.1上,listenUsingRfcommWithServiceRecord失败:wrp_sock_create:套接字创建失败(权限被拒绝)

时间:2010-07-11 00:48:46

标签: android bluetooth rfcomm

我正在尝试在Android (GT-I5700上的2.1-update1)手机上打开蓝牙服务器插槽,但它失败了。我已经没想完了。 关于我所缺少的一些指示将是受欢迎的。 蓝牙已开启,因此不应成为问题。

我也很确定权限还可以:

<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>

失败的代码非常简单:

String TAG = "MYAPP";
UUID UUID_RFCOMM_GENERIC = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
BluetoothSocket s;
BluetoothServerSocket bss;
try {
    Log.i(TAG, "We do reach this point");
    bss = adapter.listenUsingRfcommWithServiceRecord("PrettyService", UUID_RFCOMM_GENERIC); 
    Log.i(TAG, "We never reach this");
    s = bss.accept();
} catch (IOException e) {
    Log.i(TAG, "Blutooth failed");
}

日志:

INFO/MYAPP(9087): We do reach this point
DEBUG/BluetoothSocket(9087): BluetoothSocket created fd: -1uuidnullport 1
DEBUG/BluetoothSocket.cpp(9087): initSocketNative
INFO/BLZ20_WRAPPER(9087): blz20_wrp_socket: fam 31, type 1, prot BTPROTO_RFCOMM
DEBUG/BLZ20_WRAPPER(9087): blz20_init: initializing...
DEBUG/BTL_IFC_WRP(9087): wsactive_init: init active list
INFO/BTL_IFC(9087): main_client_thread: Client main thread starting
DEBUG/BLZ20_WRAPPER(9087): blz20_init: success
INFO/BTL_IFC(9087): BTL_IFC_RegisterSubSystem: Register subsystem [(null)]
INFO/BTL_IFC(9087): btl_ifc_ctrl_connect: Connect control channel for subsystem [(null)]
DEBUG/BTL_IFC_WRP(9087): wrp_sock_create: CTRL
DEBUG/BTL_IFC_WRP(9087): wrp_alloc_new_sock: wrp_alloc_new_sock sub 1
ERROR/BTL_IFC_WRP(9087): ##### ERROR : wrp_sock_create: socket create failed (Permission denied)#####
DEBUG/BTL_IFC_WRP(9087): wrp_sock_create: -1
DEBUG/BluetoothSocket.cpp(9087): socket() failed, throwing
INFO/MYAPP(9087): Blutooth failed

这个错误非常难看,谷歌搜索没有任何结果。我对整个Android世界也很陌生。

0 个答案:

没有答案