question

ramya avatar image
ramya asked parag commented

2D barcode scanner not working with BarcodeScanner

scanner.jpgHi,

2D barcode scanner not working with BarcodeScanner. But its working fine with Register app and 1D barcode scanner.

This is the code we are using

mBarcodeScanner = new BarcodeScanner(this);
registerBarcodeScanner();
Bundle extras = new Bundle();
extras.putBoolean(Intents.EXTRA_LED_ON, false);
extras.putBoolean(Intents.EXTRA_SCAN_1D_CODE, true);
extras.putBoolean(Intents.EXTRA_SHOW_PREVIEW, false);
extras.putBoolean(Intents.EXTRA_SCAN_QR_CODE, true);
extras.putBoolean(Intents.EXTRA_SHOW_MERCHANT_PREVIEW, false);
extras.putBoolean(Intents.EXTRA_SHOW_CUSTOMER_PREVIEW, false);
extras.putBoolean(Intents.EXTRA_SHOW_CLOSE_BUTTON, false);
extras.putBoolean(Intents.EXTRA_SHOW_LED_BUTTON, false);
extras.putBoolean(Intents.EXTRA_START_SCAN, true);
extras.putInt(Intents.EXTRA_SCANNER_FACING, 0);
mBarcodeScanner.executeStartScan(extras);

Can you please check it. Is anything we have to add?

clover developer communitybarcode scanner
scanner.jpg (271.7 KiB)
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jeffrey Blattman avatar image
Jeffrey Blattman answered parag commented

BarcodeScanner is for the Clover built-in (camera-based) scanner, not external USB scanners like in your image.

Also, you passed EXTRA_SCAN_1D_CODE, which means "scan only 1d barcodes". If you want both 1d and 2d don't set that. Anyway, for external USB scanners this has no effect and you'll need to refer to the scanner's documentation to understand how to configure it.

Finally, we don't support all external barcode scanners. I'd need to know the USB vendor and product ID to tell you definitively if that's a supported scanner. If you're using a linux-based system you can plug it in and do "lsusb" to find out.

If you connect an unsupported USB scanner it's going to act like a USB HID device; you can scan codes, and the they'll be sent as keyboard events, but there won't be any barcode scan broadcast (see BarcodeResultr in the SDK). Unless you have a text field focused Clover apps only react to the broadcast, not keyboard events.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

parag avatar image parag commented ·

I am getting barcode scanned value using dispatchKeyEvent with below source code and devices

Honeywell IHS320X (https://www.amazon.in/IMPACT-Honeywell-IHS320X-Barcode-Scanner/dp/B0C1VSH8GX)

Tvs BS-L100 (https://www.amazon.in/Tvs-BS-I100N-Barcode-Scanner-creators/dp/B07CNFB7N3)


@Override
public boolean dispatchKeyEvent(KeyEvent event) {
                    
super.dispatchKeyEvent(event);
if ( event.getAction() == KeyEvent.ACTION_DOWN) {
                    
if(event.getKeyCode() == KeyEvent.KEYCODE_ENTER){
                    
handleBarcodeScan(scannedBarcode.toString());
scannedBarcode.setLength(0);
return true;
} else{
                    
scannedBarcode.append(event.getDisplayLabel());
}
}
return true;
}

But facing issue client's barcode scanner, Client is using Zebra DS2200 (https://www.zebra.com/us/en/products/scanners/general-purpose-handheld-scanners/ds2200-series.html)

Zebra DS2200 is able to scan with Clover Register app


Also added Broadcast receiver

<receiver
android:name=".services.BarcodeScannerReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.clover.sdk.action.CODE_SCAN" />
</intent-filter>
</receiver>

Also tried below clover SDK example


https://github.com/clover/android-examples/tree/master/barcodereceiver/app/src/main/java/com/clover/example/barcodereceiver/app

Please let us know if missing anything else from my end

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community