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

Show the scanner

You can use our samples to get a good overview of how to show the barcode scanner in an app: Run the Scandit Samples.

The scan view (BarcodePicker) is a RelativeLayout and therefore a normal view in Android. You can add it to the view hierarchy like any other view and add further views on top of the scan view.


Displaying the scan view in fullscreen

To display the scan view in fullscreen the best option is to open an Activity for it and set the barcode picker as the content view.

// Set license key. This will only have to be done once
ScanditLicense.setAppKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
// Create the scan view. Note that you will have to configure the settings since the
// default settings have all symbologies disabled and you won't be able to scan anything.
BarcodePicker barcodePicker = new BarcodePicker(context, ScanSettings.create());
// Add scan view as the activity's root view
setContentView(picker);


Adding the scan view as a subview

As the BarcodePicker is a normal RelativeLayout you can add it to your own layout like any other view:

// Set license key. This will only have to be done once
ScanditLicense.setAppKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
// Create the scan view. Note that you will have to configure the settings since the
// default settings have all symbologies disabled and you won't be able to scan anything.
BarcodePicker barcodePicker = new BarcodePicker(context, ScanSettings.create());
// Add the scan view to the root view.
rootView.addView(barcodePicker);


Scaling and/or Cropping the subview

To scale and/or crop the scan view you only need to change its width and height. Here is a small example of scaling the scan view to 3/4 of its width and 1/2 of its height (meaning 1/12 of its height will be cropped at the top and 1/12 at the bottom):

// Set license key. This will only have to be done once
ScanditLicense.setAppKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
// Create the scan view. Note that you will have to configure the settings in your app
// since the default settings have all symbologies disabled and you won't be able
// to scan anything.
BarcodePicker barcodePicker = new BarcodePicker(context, ScanSettings.create());
// Get the device's display for width and height.
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
// Create layout parameters to scale it to 3/4 of its size.
RelativeLayout.LayoutParams rParams = new RelativeLayout.LayoutParams(
display.getWidth() * 3 / 4, display.getHeight() / 2);
rParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
// Add the scan view to the root view.
rootView.addView(barcodePicker, rParams);