Deprecation warning

Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.

We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.

You'll find the updated documentation at: Data Capture SDK Documentation for Android

Scanning Multiple Barcodes

Motivation

Sometimes you can find several barcodes in the same package/pallet, with the Scandit Barcode Scanner you can scan all the codes at the same time, saving time and money. With very little code it is possible to get it.

Steps

To implement multiple barcode scanning

  • Set the code duplicated filter setCodeDuplicateFilter(int) -1, so each unique code is only added once to the session.
  • Set the maximum number of codes to be decoded every frame setMaxNumberOfCodesPerFrame(int)
  • In the didScan function, wait unil the number of expected codes have been decoded, then store the codes and pause and clean the session.
ScanSettings settings = SettingsActivity.getSettings(this);
//barcodes are filtered as duplicates
//if they match an already decoded barcode in the session
settings.setCodeDuplicateFilter(-1);
//the maximum number of codes to be decoded every frame
settings.setMaxNumberOfCodesPerFrame(3);
@Override
public void didScan(ScanSession session) {
// number of expected barcodes
int numExpectedCodes = 3;
// get all the scanned barcodes from the session
List<Barcode> allCodes = session.getAllRecognizedCodes();
// if the number of scanned codes is greater or equal than the number of expected barcodes
// pause the scanning and clear the session (to remove recognized barcodes).
if (allCodes.size() >= numExpectedCodes) {
// pause scanning and clear the session. The scanning itself is resumed
// when the user taps the screen.
session.pauseScanning();
session.clear();
…...
}
}