Code example for BluetoothAdapter

Methods: listenUsingRfcommWithServiceRecord

  private Thread thread = new Thread(this, "Bluetooth server");
  private InputListener listener;
  BluetoothServerPort(BluetoothAdapter adapter, UUID uuid)
    throws IOException { 
    serverSocket = adapter.listenUsingRfcommWithServiceRecord("XCSoar", uuid);
  @Override public void run() { 
    while (true) { 
      try { 
        BluetoothSocket socket = serverSocket.accept();
        Log.i(TAG, "Accepted Bluetooth connection from " +
        BluetoothPort port = new BluetoothPort(socket);
        /* make writes non-blocking and potentially lossy, to avoid 
           blocking when one of the peers doesn't receive quickly 
Contextual code suggestions in your IDE  Get Codota for Java