Deprecation warning

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

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

New Features in Android Scandit Barcode Scanner 4.3

As part of our ongoing work to make the Scandit Barcode Scanner faster, we made significant changes to the internals of our Android API. The result is a significantly improved scan performance. At the same time, the restructuring has given us the chance to reevaluate many of the design decisions we have made in the early days of the Scandit Barcode Scanner. The current 4.3 introduces a new API which is based on our insights and feedback we have received from our clients.

Please note that while this new API is available as of 4.3, the API of Scandit Barcode Scanner 4.2 and earlier is still available and applications can continue to use it. We do, however, recommend users to switch to the new API as the existing API will eventually be phased out.

Scan Sessions

The new 4.3 API introduces scan sessions to keep track of decoded barcodes over a set of frames (a session). Scan sessions are used in the new ScanditSDKOnScanListener interface.

The scan session performs and gives control over

  • duplicate removal, e.g. how decoded barcodes with the same symbology/data are handled.
  • keeping track of barcodes over a succession of multiple frames

Configuring Scan Session

For single-scan scenarios, the default settings for scan settings work fine. Configuration changes are only required when collecting multiple barcodes over a succession of multiple frames.

The scan sessions are configured when instantiating the barcode picker as part of the ScanditSDKScanSettings interface.

The code duplicate filter controls how scans of the same barcode (data and symbology) are handled. By default, the duplicate filter is set to a value of 500ms. Scans of the same barcode are filtered out as duplicates if they happen within 500ms of the first scan. By setting the duplicate filter to 0, duplicate filtering is disabled and every scan is reported.

Code caching controls how long the barcodes are kept in the session. By default, the barcodes are cached for the lifetime of the session, but the caching can be configured to drop the codes after a certain number of seconds.

Transitioning to 4.3

Replacing ScanditSDKListener with ScanditSDKOnScanListener

The ScanditSDKListener interface has been replaced by ScanditSDKOnScanListener. Like ScanditSDKListener.didScanBarcode, ScanditSDKOnScanListener.didScan is invoked every time a new barcode is scanned. The key differences are:

  • instead of a single barcode data and symbology pair, the didScan callback receives a scan session as its first argument. The scan session holds a list of all barcodes which have been decoded in the current session (see above).
  • the scan session can be configured how it handles barcode duplicates, e.g. barcodes with the same data and symbology that are scanned in different frames.
  • the didScan listener is executed in the thread running the recognition engine and not in the main UI thread. To do any GUI work, you must post a runnable/message to the UI thread.

Below are two typical implementations for a didScan callback

Single Scan Example

This illustrates a common use case, where one code is scanned after which the picker is closed.

public void didScan(ScanditSDKScanSession session) {
for (ScanditSDKCode code : session.getNewlyDecodedCodes()) {
// do something with the code

Multi Scan Example:

The next code-snippet is a made-up example in which two different barcodes are required to be present. One has to start with “1” the second one with “2”. When both barcodes have been found, the scanning is stopped:

public void didScan(ScanditSDKScanSession session) {
boolean foundCodeWithOne = false;
boolean foundCodeWithTwo = false;
for (ScanditSDKCode code : session.getAllCodes()) {
if (code.getData().startsWith("1")) {
foundCodeWithOne = true;
if (code.getData().startsWith("2")) {
foundCodeWithTwo = true;
if (foundCodeWithOne && foundCodeWithTwo) {
// finally, we have found both codes...
// stop the scanning

Picker Setup

ScanditSDK 4.3 also introduces a new way to specify the scan settings of the barcode picker. The settings are all contained in the ScanditSDKScanSettings object. These settings are passed to the ScanditSDKBarcodePicker constructor. The new interface offers speed advantages, since it allows the settings of the picker to be known at construction time. Certain resources which are expensive do not need to be loaded/created if it is known at construction time that the features requiring these resources are not enabled.

For ScanditSDK 4.2 and older, a number of symbologies are enabled by default. When using the new scan settings interface, all barcode symbologies are turned off. This avoids having to turn off symbologies which are not required and improves performance. To scan codes of a certain symbology, the symbology needs to be enabled.


ScanditSDKScanSettings settings = ScanditSDKScanSettings.getDefaultSettings();
// enable EAN13, all other symbologies are off
ScanditSDKBarcodePicker picker = null;
picker = new ScanditSDKBarcodePicker(MY_APP_KEY, settings);

Old API:

ScanditSDKBarcodePicker picker = null;
picker = new ScanditSDKBarcodePicker(MY_APP_KEY, ScanditSDK.CAMERA_FACING_BACK);
// disable all symbologies that are on by default, except EAN13