Search code examples
androidzxingbarcode-scanner

Android - How to disable QR Code scanning in ZXing Library and allow only Bar code scaning


I want to give 2 options in My Code for Zxing Bar scanning.

Options:

  1. Scan Bar Code
  2. Scan QR Code.

After selecting first option only Bar-Code should get scan by ZXing Library and same for option two.

Please help me with the code if any flag is there in Zxing to enable and disable.


Solution

  • I have tested its working for me

    For QR code scan use

      IntentIntegrator integrator = new IntentIntegrator(this);
      integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
      integrator.setPrompt("Scan a Qr code");
      integrator.setCameraId(0);  // Use a specific camera of the device
      integrator.setBeepEnabled(false);
      integrator.setBarcodeImageEnabled(true);
      integrator.initiateScan();
    

    and for bar code use

        IntentIntegrator integrator = new IntentIntegrator(this);
        integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
        integrator.setPrompt("Scan a barcode");
        integrator.setCameraId(0);  // Use a specific camera of the device
        integrator.setBeepEnabled(false);
        integrator.setBarcodeImageEnabled(true);
        integrator.initiateScan();