title: Pair a bluetooth device in Android Studio
body: <p>I'm creating an app that should connect via bluetooth to a specific device.</p>
  
  <p>I want my app to connect with this device no matter it is already paired or not.</p>
  
  <p>For now I have this </p>
  
  <pre><code>private void findDevice() {
      Set&lt;BluetoothDevice&gt; pairedDevices = bluetoothAdapter.getBondedDevices();
      if (pairedDevices.size() &gt; 0) {
          for (BluetoothDevice device : pairedDevices) {
              if (device.getName().equals(DEVICE_NAME)) {
                  bluetoothDevice = device;
                  deviceFound = true;
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>But this function connects only to paired devices.
  If my device isn't already paired, I want to pair it.
  Have no idea how to do this.</p>
  
  <p>Can someone get me any advice please?</p>