ForeverWintr ForeverWintr - 1 year ago 136
Android Question

Android: How do bluetooth UUIDs work?

Basically, I don't understand what a bluetooth UUID denotes. Do UUIDs denote protocols (e.g. RFCOMM)? If so, why do the

methods require UUIDs, when they specify rfcomm right in their names? Why does the BluetoothChat sample code have a seemingly arbitrary, hardcoded UUID?

My question arises because, as per this question, I'm getting a null pointer exception when devices running 4.0.4 try to connect (to an external, non-android device) using reflection. However, the solution to that question doesn't work for me.
UUID muuid = device.getUuids()[0].getUuid();
raises an exception.

Edit: I've solved that problem by hardcoding the UUID for Serial port service as per this answer (using

I'm further puzzled by why I need to supply a UUID to create an unsecured rfcomm socket using
but not using the reflection method.

Can anyone straighten me out?

Answer Source

It usually represents some common service (protocol) that bluetooth device supports.

When creating your own rfcomm server (with listenUsingRfcommWithServiceRecord), you should specify your own UUID so that the clients connecting to it could identify it; it is one of the reasons why createRfcommSocketToServiceRecord requires an UUID parameter.

Otherwise, some common services have the same UUID, just find one you need and use it.

See here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download