title: How to search for Bluetooth devices?
body: <p>I want to build an app that scan for local Bluetooth devices. The app finds all paired devices, but no unpaired device. I have a button and when I press it I want to see in the <code>Log</code> found devices.</p>
  
  <p>In the <code>AndroidManifest</code> I added permissions for <code>BLUETOOTH</code>, <code>BLUETOOTH_ADMIN</code> and <code>ACCESS_COARSE_LOCATION</code>. </p>
  
  <p><code>onCreate</code> I get the default BluetoothAdapter and get the paired Devices.</p>
  
  <pre class="lang-java prettyprint-override"><code>protected void onCreate(Bundle savedInstanceState) {
  ....
      bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
          if(!bluetoothAdapter.isEnabled()) {
              Intent enable = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
              startActivityForResult(enable, REQUEST_ENABLE_BT);
          }
      pairedDevices = bluetoothAdapter.getBondedDevices();
          ///Add paired Devices
          for(BluetoothDevice device : pairedDevices){
              Log.i("DEVICE", device.getAddress()+" "+device.getName());
              devicesList.add(device);
          }
  }
  </code></pre>
  
  <p>At <code>onClick</code> I do the <code>scanDevices</code> function where I use a <code>ScanCallBack</code>.</p>
  
  <pre><code>final ScanCallback scanCallback = new ScanCallback() {
      @Override
      public void onScanResult(int callbackType, ScanResult result) {
         super.onScanResult(callbackType, result);
         if(!devicesList.contains(result.getDevice())) {
            Log.i("DEVICE", result.getDevice().getName()+ "  "+result.getDevice().getAddress());
            devicesList.add(result.getDevice());
                  }
              }
              @Override
              public void onScanFailed(int errorCode) {
                  super.onScanFailed(errorCode);
              }
          };
  
   bluetoothAdapter.getBluetoothLeScanner().startScan(scanCallback);
   new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {
                bluetoothAdapter.getBluetoothLeScanner().stopScan(scanCallback);     
              }
          }, 10000);
  }
  </code></pre>
  
  <p>When I start the app it doesn't do anything,no device printed in the Log, and when I try to debug it it doesn't even stop in the ScanCallBack.</p>