title: Android: How do bluetooth UUIDs work?
body: <p>I don't understand what a bluetooth UUID denotes. Do UUIDs denote protocols (e.g. <a href="http://www.bluecove.org/bluecove/apidocs/javax/bluetooth/UUID.html" rel="noreferrer">RFCOMM</a>)? If so, why do the <code>createRfcommSocketToServiceRecord()</code> methods require UUIDs, when they specify rfcomm right in their names? Why does the BluetoothChat sample code have a seemingly arbitrary, hardcoded UUID?</p>
  
  <p>My question arises because, as per <a href="https://stackoverflow.com/questions/12485785/nullptr-exception-on-socket-connect-galaxy-tab-2-running-android-4-04">this question</a>, 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. <code>UUID muuid = device.getUuids()[0].getUuid();</code> raises an exception. </p>
  
  <p><strong>Edit</strong>: I've solved that problem by hardcoding the UUID for Serial port service as per <a href="https://stackoverflow.com/a/11622794/1286571">this answer</a> (using <code>UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");</code>).</p>
  
  <p>I'm further puzzled by why I need to supply a UUID to create an unsecured rfcomm socket using <code>createInsecureRfcommSocketToServiceRecord(),</code> but not using the reflection method. </p>
  
  <p>Can anyone straighten me out?</p>