title: How to get and/or set the link key when pairng bluetoth devices using Android(Java)?
body: <p>I'm really new on this of Android development, so I have many questions. Right now I'm trying to connect two devices via Bluetooth. So far I was able to do this, I have connected two tablets, but now I'm asked to save the LinkKey and use some bytes of it to create a PIN. So, how can I get that LinkKey? I've read that it's saved on both devices for future connections, but I don't know how to get it.</p>
  
  <p>Also, I've read that this devices can delete those LinkKey, what happens then? If they try to connect with each other again, will they use the same LinkKey or a new one is created?</p>
  
  <p>And the last thing. I have to connect a tablet to a device that has neither a display nor a keypad, a normal bluetooth connection is enough? I'm doing this to stablish the connection:</p>
  
  <pre><code>final UUID MY_UUID = UUID.randomUUID();
          //tmp = device.createRfcommSocketToServiceRecord(MY_UUID);
          Method m = null;
          try {
              m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
          } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          tmp = (BluetoothSocket) m.invoke(device, 1);
          mmSocket = tmp;
  
  
      Thread connectionThread = new Thread(new Runnable(){
  
      public void run() {
          // Cancel discovery because it will slow down the connection
          mBluetoothAdapter.cancelDiscovery();
  
          try {
              // Connect the device through the socket. This will block
              // until it succeeds or throws an exception
              mmSocket.connect();
          } catch (IOException connectException) {
              // Unable to connect; close the socket and get out
              try {
                  mmSocket.close();
              } catch (IOException closeException) { }
              return;
          }
  
          // Do work to manage the connection (in a separate thread)
          manageConnectedSocket(mmSocket);
      }
  </code></pre>
  
  <p>Thanks.</p>