title: get two BLE device with onScanResult in android
body: <p>I tried to get two device name and address inside onScanResult function in Android but I couldn't get these information. As I understand this function call peridicly itself until stop searching and the function give some result about the founded device but I couldn't get how many device found and device information at the same time.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>private ScanCallback scanCallback = new ScanCallback() {
      @Override
      public void onScanResult(int callbackType, ScanResult result) {
  
          if("MyBLEdevice".equals(result.getDevice().getName())){
              bleDevice = result.getDevice();
              if(bleScanner !=null){
                  bleScanner.stopScan(scanCallback);
              }
  
          }
  
          super.onScanResult(callbackType, result);
      }
  };
  </code></pre>
  
  <p>I change my code but I couldn't stop scanResult</p>
  
  <pre><code>boolean isDuplicate = false;
  private ScanCallback scanCallback = new ScanCallback() {
      @Override
      public void onScanResult(int callbackType, ScanResult result) {
  
          if("MyBLEdevice".equals(result.getDevice().getName())){
  
              for(BluetoothDevice device : mLeDevices)
              {
                  if(device.getAddress().equals(result.getDevice().getAddress())){
                      isDuplicate = true;
                  }
                  if(!isDuplicate){
                      mLeDevices.add(result.getDevice());
                  }
                  if(mLeDevices.size()==2)
                  {
                      bleScanner.stopScan(scanCallback);
                      bleScanner.flushPendingScanResults(scanCallback);
                  }
  
              }
  
          }
  
          super.onScanResult(callbackType, result);
      }
  };
  </code></pre>