Skip to main content
Version: 7.0.0

Migrate from Barcode Scanner 5.x

This guide will help you migrate from Barcode Scanner 5.x to version 6.x of the Scandit Smart Data Capture SDK. Version 6.0 introduces all new APIs that are not backwards compatible with apps using ScanditSDK 5.x. To migrate your code to SDK 6.0 and newer, you will need to modify your app.

If you are unsure about how to perform the migration or the feature you are using is not covered in this migration guide, please reach out to our support team.

Replace the BarcodePicker

In 5.x, the BarcodePicker (SBSBarcodePicker on iOS) was the central class that manages recognition, renders the video preview and provides means to configure what barcodes get scanned. In 6.0 and newer, there is no direct equivalent to the BarcodePicker. Instead this functionality is covered by multiple classes:

In your app you will need to use all of these classes to implement the functionality offered by the BarcodePicker. The following sample code shows you how to do this:

dataCaptureContext = DataCaptureContext.forLicenseKey(SCANDIT_LICENSE_KEY);

// Device's camera will serve as a frame source.
camera = Camera.getDefaultCamera();
dataCaptureContext.setFrameSource(camera, null);

// See below for differences between 5.x and 6.x.
BarcodeCaptureSettings barcodeCaptureSettings = new BarcodeCaptureSettings();
barcodeCaptureSettings.enableSymbology(Symbology.EAN13_UPCA);

barcodeCapture = BarcodeCapture.forDataCaptureContext(dataCaptureContext, barcodeCaptureSettings);
barcodeCapture.addListener(this);
barcodeCapture.setEnabled(true);

BarcodeCaptureOverlay overlay = new BarcodeCaptureOverlay(barcodeCapture);

dataCaptureView = DataCaptureView.newInstance(this, dataCaptureContext);
dataCaptureView.addOverlay(overlay);

setContentView(dataCaptureView);

Start/Stop the Capture Process

In 5.x the scan process was started by calling startScanning on the BarcodePicker. In 6.0+, the equivalent functionality is to switch the frame source from off to on<IFrameSource.SwitchToDesiredStateAsync> and to enable the capture mode<IDataCaptureMode.IsEnabled>.

Capture modes are enabled by default, the first line to enable the capture mode is only required when you are reusing a previously disabled data capture mode.

barcodeCapture.setEnabled(true);
camera.switchToDesiredState(FrameSourceState.ON, null);

To pause the barcode capture process, simply set the barcode.BarcodeCapture.IsEnabled property to false (without turning the camera off). To resume the capture process, set the barcode.BarcodeCapture.IsEnabled property back to true.

To stop the barcode capture process and turn the camera off, disable the capture mode and turn the camera off, as shown below:

barcodeCapture.setEnabled(false);
camera.switchToDesiredState(FrameSourceState.OFF, null);

Barcode Scanner Changes

  • The default code duplicate filter has been changed from 500ms to 0ms. This means that a barcode that gets scanned in two consecutive scans will get reported twice. When you pause/stop the scanning as soon as one code gets scanned, the code duplicate filtering setting does not affect you. However if you continue scanning further codes without pausing/stopping recognition, you may want to change the barcode.BarcodeCaptureSettings.CodeDuplicateFilter property back to 500ms.
  • EAN13 and UPCA used to be separate symbologies in 5.x but have now been merged into one symbology called Ean13Upca.
  • The leading zero of UPCA codes is no longer removed by default. If you rely on this behavior in your app, you can either remove the leading zero yourself, or enable the remove_leading_upca_zero extension:
settings.getSymbologySettings(Symbology.EAN13_UPCA)
.setExtensionEnabled("remove_leading_upca_zero", true)
  • The API to configure the active scan area has been overhauled and simplified. If you were changing the active scan area to match the visible part of the preview, the good news is that the active scan area is now automatically restricted to the visible part of the preview.
  • The camera-related settings have been moved from ScanSettings to CameraSettings. For example, if you want to change the preview resolution from 720p to 1080p, set the CameraSettings.PreferredResolution to VideoResolution.FullHd and apply the new settings<Camera.ApplySettingsAsync> to the camera.

MatrixScan Changes

important

Not applicable for Web and Titanium.

The features that you know under the name MatrixScan are now bundled under barcode.tracking.BarcodeTracking, the overall concept is still referred to as MatrixScan.

In 5.x setMaxNumberOfCodesPerFrame was used to adjust MatrixScan to specific use cases where more or less codes had to be tracked. In 6.x it is no longer needed to set this number, instead it is selected automatically depending on the license, use case, and enabled symbologies.

Migrate the Scan UI

Without any further configuration, the default UI renders the Scanning by Scandit logo in the bottom-right corner of the data capture view. To replicate the default look from 5.x, you need to create a viewfinder.

note

This functionality is only available for barcode capture, but not barcode tracking (MatrixScan).

Enable the Rectangular Viewfinder

To enable the rectangular viewfinder<ui.RectangularViewfinder> (previously called the default viewfinder), use the following lines of code:

BarcodeCaptureOverlay overlay = new BarcodeCaptureOverlay(barcodeCapture);
RectangularViewfinder viewfinder = new RectangularViewfinder();
overlay.setViewfinder(viewfinder);

dataCaptureView = DataCaptureView.newInstance(this, dataCaptureContext);
dataCaptureView.addOverlay(overlay);

Change the Viewfinder Size

To change the size of the viewfinder using sizes relative to the data capture view (same as in 5.x), you can use the following lines of code:

viewfinder.setSize(new SizeWithUnit(new FloatWithUnit(0.8f, MeasureUnit.FRACTION),
new FloatWithUnit(0.4f, MeasureUnit.FRACTION)));

Other Changes

important

Not applicable for Web.

The short 43 character legacy app keys supported in 4.x and 5.x have been deprecated and are not compatible with 6.0+ anymore. Please contact support to get your new license keys.