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 samples.

Once you have created a view through scanditsdk.createView() and initialized said view with init() you have a reference to a normal view that can be added to any view hierarchy like any other view. It is of course also possible to put 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 create it with 100% size, add it to a window and open said window.

var scanditsdk = require("com.mirasense.scanditsdk");
// Create a window.
var window = Titanium.UI.createWindow({
title:'Scandit SDK',
navBarHidden:true
});
// Set the license key.
scanditsdk.appKey = "your_scandit_license_key";
// Instantiate the Scandit SDK Barcode Picker view.
picker = scanditsdk.createView({
width:"100%",
height:"100%"
});
// Initialize the barcode picker.
picker.init();
// Add it to the window and open it.
window.add(picker);
window.open();


Adding the scan view as a subview

As the barcode picker is a normal view you can add it to your own container-view like any other view:

var scanditsdk = require("com.mirasense.scanditsdk");
// Instantiate the Scandit SDK Barcode Picker view.
picker = scanditsdk.createView({
width:"100%",
height:"100%"
});
// Set the license key.
scanditsdk.appKey = "your_scandit_license_key";
// Initialize the barcode picker.
picker.init("yourlicenseKey", 0);
// Add it to your container-view.
yourContainerView.add(picker);


Scaling/cropping the subview

To scale or crop the scan view you only need to change its width and height. The camera feed will automatically scale and crop itself accordingly and the UI adjusts to the new size.

var scanditsdk = require("com.mirasense.scanditsdk");
// Instantiate the Scandit SDK Barcode Picker view with width and height at 75%.
picker = scanditsdk.createView({
width:"75%",
height:"75%"
});
// Set the license key.
scanditsdk.appKey = "your_scandit_license_key";
// Initialize the barcode picker.
picker.init("yourLicenseKey", 0);
// Add it to your container-view.
yourContainerView.add(picker);