Rohan Zemse
Rohan Zemse

Reputation: 49

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.

Upvotes: 2

Views: 3562

Answers (2)

Anil
Anil

Reputation: 1615

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();

Upvotes: 1

Shinoo Goyal
Shinoo Goyal

Reputation: 621

For scanning QR Code:

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");

For scanning bar code:

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");

Upvotes: 2

Related Questions