views:

396

answers:

1

I'm trying to open a bluetooth server socket on an Android (2.1-update1 on a GT-I5700) phone and it fails. I have run out of ideas. Some pointers on what I am missing would be welcome. Bluetooth is on, so that shouldn't be a problem.

I'm also pretty sure permissions are ok:

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

The code which fails is pretty simple:

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");
}

And the log:

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

That error is pretty ugly and googling turns up nothing. I am also quite new to the whole Android world.

A: 

Did you solved this issue ?, I also facing with the same problem, please help if you did it.

Anzi
I couldn't solve it.
Kalmi