title: Bluetooth LE devices not detected
body: <p>My app needs to connect to a Bluetooth Low Energy device, and obviously the first step is to detect it. I have written the code bellow to do just that. When I run the app I have another BLE device (Xperia M2) beside my Dev phone (Huawei P8 Lite) with Bluetooth ON and discoverable, however, nothing get printed on the logcat. Is the device truly not being discovered or is the callback function not being called/malfunctioning. What can I do to identify which one of this situations is happening?</p>
  
  <p>The <code>scanBluetoothMethod</code> is called elsewhere in the code.</p>
  
  <pre><code>private BluetoothManager bluetoothManager;
  private BluetoothAdapter bluetoothAdapter;
  private static final long SCAN_PERIOD = 10000;
  private BluetoothLeScanner scanner;
  private Handler scanHandler = new Handler();
  private List&lt;ScanFilter&gt; scanFilters = new ArrayList&lt;ScanFilter&gt;();
  private ScanSettings scanSettings;
  private boolean scanRunning=false;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_add_pandlet);
  
      ...
  
      bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
      bluetoothAdapter = bluetoothManager.getAdapter();
  }
  
  
  private void scanBluetoothLE() {
  
      if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
          Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
          startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
          return;
      }
  
      progressDialog = new ProgressDialog(this);
      progressDialog.setMessage(getString(R.string.addpandlet_searchingforbledevices));
      progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
      progressDialog.setCancelable(false);
      progressDialog.setCanceledOnTouchOutside(false);
      progressDialog.setIndeterminate(true);
      progressDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.addpandlet_cancelsearch), new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              scanner.stopScan(scanCallback);
              scanHandler.removeCallbacks(scanRunnable);
              scanRunning = false;
              return;
          }
      });
  
  
      ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder();
      //scanSettingsBuilder.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES);
      scanSettingsBuilder.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY);
      scanSettings = scanSettingsBuilder.build();
  
      scanHandler.post(scanRunnable);
  
  }
  
  
  private Runnable scanRunnable = new Runnable() {
      @Override
      public void run() {
          scanner = BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner();
  
          if (scanRunning) {
              scanner.stopScan(scanCallback);
              progressDialog.hide();
              scanRunning = false;
          } else {
              scanRunning = true;
              progressDialog.show();
              scanHandler.postDelayed(this, SCAN_PERIOD);
              scanner.startScan(scanFilters, scanSettings, scanCallback);
          }
      }
  };
  
  
  private ScanCallback scanCallback = new ScanCallback() {
      @Override
      public void onScanResult(int callbackType, ScanResult result) {
  
          System.out.println(result.getRssi() + " " + result.getDevice().getName() );
  
          super.onScanResult(callbackType, result);
  
      }
  
      @Override
      public void onScanFailed(int errorCode) {
          System.out.println("Error code " + errorCode );
  
          super.onScanFailed(errorCode);
  
      }
  };
  
  
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      if( requestCode == REQUEST_ENABLE_BT &amp;&amp; resultCode == Activity.RESULT_OK )
          scanBluetoothLE();
  
  
  }
  </code></pre>