public void scanNow() {
   IntentIntegrator integrator = new IntentIntegrator(this);
   integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
   integrator.setPrompt("Scan a barcode");
   integrator.setResultDisplayDuration(0);
   integrator.setWide(); // Wide scanning rectangle, may work better for 1D barcodes
   integrator.setCameraId(0); // Use a specific camera of the device
   integrator.initiateScan();
 }
  /**
   * event handler for scan button instantiates an instance of the Intent Integrator and send an
   * Intent to the barcode scanner of the device.
   *
   * @param view view of the activity
   */
  public void scanQR(View view) {

    // create an instance of the integrator class which
    // will send the scan intent to the devices barcode scanner
    IntentIntegrator integrator = new IntentIntegrator(this);
    // sets the type of code that will be scanned
    integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
    integrator.setPrompt(String.valueOf(R.string.txt_scan_qrcode));
    integrator.setResultDisplayDuration(0);
    integrator.setCameraId(0); // Use a specific camera of the device
    integrator.initiateScan(); // starts the scan
  }