title: How to capture the image simultaniously while scanning QR code in Android?
body: <p>I want to <strong>capture the image of QR code which comes under rectangular brackets while scanning</strong>. I know that QR code image can be easily generated and displayed but my requirement is to display the exact same image of QR code which is scanned.  </p>
  
  <p>I have tried below code:</p>
  
  <pre><code>scan_btn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  IntentIntegrator integrator = new IntentIntegrator(activity);
                  integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
                  integrator.setPrompt("Scan");
                  integrator.setCameraId(0);
                  integrator.setBeepEnabled(false);
                  integrator.setBarcodeImageEnabled(false);
                  integrator.initiateScan();
              }
          });
  
  .....
  
  @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
          if (result != null){
              Bitmap btm = (Bitmap) data.getExtras().get("data");
  
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
              btm.compress(Bitmap.CompressFormat.PNG, 100, stream);
              image.setImageBitmap(btm);
              if(result.getContents() == null){
  
                  android.widget.Toast.makeText(this, "You cancelled the scanning", Toast.LENGTH_LONG).show();
              }
              else {
                  android.widget.Toast.makeText(this, result.getContents(), Toast.LENGTH_LONG).show();
              }
  
          }
          else {
              super.onActivityResult(requestCode, resultCode, data);
          }
      }
  </code></pre>
  
  <p>But I am getting null bitmap.</p>