title: Suspend QR code detection while dialog is shown
body: <p>I'm trying to create a real time QR Code decoder which allows user to confirm/cancel data read from the camera view.
  (Of course, according confirmation or cancelation, it will execute some code...)</p>
  
  <p>But there's a bad point:
  The app I coded keeps reading qr code data even while in dialog and I can't find a way to prevent it.</p>
  
  <p>Here is my main activity:</p>
  
  <pre><code>public class MainReadActivity extends Activity {
  
  
  private SurfaceView cameraView;
  private TextView barcodeInfo;
  private BarcodeDetector barcodeDetector;
  private CameraSource cameraSource;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_read);
  
      DisplayMetrics dm = new DisplayMetrics();
      getWindowManager().getDefaultDisplay().getMetrics(dm);
  
  
      cameraView = (SurfaceView) findViewById(R.id.camera_view);
  
      cameraView.requestFocus();
      barcodeInfo = (TextView) findViewById(R.id.code_info);
  
      barcodeDetector = new BarcodeDetector.Builder(this).setBarcodeFormats(Barcode.QR_CODE).build();
  
  
      cameraSource = new CameraSource.Builder(this, barcodeDetector).build();
  
  
      cameraView.getHolder().addCallback(new SurfaceHolder.Callback() {
  
          @Override
          public void surfaceCreated(SurfaceHolder holder) {
  
  
              try {
                  cameraSource.start(cameraView.getHolder());
              } catch (IOException ie) {
                  Log.e("CAMERA SOURCE", ie.getMessage());
              }
  
          }
  
          @Override
          public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
          }
  
          @Override
          public void surfaceDestroyed(SurfaceHolder holder) {
              cameraSource.stop();
          }
      });
  
  
      barcodeDetector.setProcessor(new Detector.Processor&lt;Barcode&gt;() {
          @Override
          public void release() {
          }
  
          @Override
          public void receiveDetections(Detector.Detections&lt;Barcode&gt; detections) {
              final SparseArray&lt;Barcode&gt; barcodes = detections.getDetectedItems();
  
              if (barcodes.size() != 0) {
                  barcodeInfo.post(new Runnable() {    // Use the post method of the TextView
                      public void run() {
  
                          ConfirmationDialogFragment myDialog = new ConfirmationDialogFragment();
                          myDialog.show(getFragmentManager(),"");
                          barcodeInfo.setVisibility(View.VISIBLE);
                          barcodeInfo.setText(barcodes.valueAt(0).displayValue);
                      }
                  });
              }
          }
      });
  
  
  
  }
  </code></pre>
  
  <p>And here is my DialogFragment:</p>
  
  <pre><code>public class ConfirmationDialogFragment extends DialogFragment {
  
  
  
  public Dialog ConfirmationDialogFragment(Bundle savedInstanceState){
  
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      LayoutInflater inflater = getActivity().getLayoutInflater();
      View v = inflater.inflate(R.layout.dialog_confirmation,null);
      builder.setView(v);
  
  
      Dialog dialog = builder.create();
  
      return dialog;
  }
  }
  </code></pre>
  
  <p>Can anyone help me?</p>
  
  <p>Bests,
  P.</p>