Skip to main content

Barcode Scanner | Xamarin Barcode Scanner

RTU UI Components#

The Ready-To-Use UI (RTU UI) Components is an easy way to integrate and customize high-level UI components (View Controllers for iOS and Activities for Android) for the most common tasks in Scanbot Barcode Scanner SDK. The design and behavior of these RTU UI Components are based on our many years of experience as well as the feedback from our SDK customers.

If you need more customization options you have to implement custom screens (View Controllers for iOS and Activities for Android) using our Classical UI Component (not available for Xamarin forms).

RTU UI Example#

var configuration = new BarcodeScannerConfiguration();BarcodeResultBundle result = await SBSDK.Scanner.Open(config);

For a fully fledged example, please see our example app scanbot-barcode-scanner-sdk-example-xamarin on GitHub.

Classical UI Components#

Our Classical UI Components allows you to build custom screens which are very flexible and fully customizable. It is a set of easy to integrate and customize components (Views, Buttons, Handlers, Controllers, etc.) which can be embedded and extended in your custom screens.

For more details please see the documentation of our native Barcode Scanner SDKs for iOS and Android as well as our example apps.

For a fully functional example, please see our example app scanbot-barcode-scanner-sdk-example-xamarin on GitHub.

Classical UI Example#

public class CameraViewActivity : AppCompatActivity, ICameraOpenCallback, IPictureCallback{    ScanbotCameraView cameraView;    ImageView resultView;
    bool flashEnabled;    BarcodeDetectorFrameHandler handler;
    const int REQUEST_PERMISSION_CODE = 200;
    protected override void OnCreate(Bundle savedInstanceState)    {        base.OnCreate(savedInstanceState);
        cameraView = FindViewById<ScanbotCameraView>(;        resultView = FindViewById<ImageView>(Resource.Id.result);
        var SDK = new ScanbotBarcodeScannerSDK(this);        handler = BarcodeDetectorFrameHandler.Attach(cameraView, SDK.BarcodeDetector());        handler.SetDetectionInterval(1000);        handler.AddResultHandler(new BarcodeResultDelegate());        handler.SaveCameraPreviewFrame(true);
        var snappingcontroller = BarcodeAutoSnappingController.Attach(cameraView, handler);        snappingcontroller.SetSensitivity(1f);        cameraView.AddPictureCallback(new PictureCallbackDelegate());    }
    protected override void OnResume()    {        base.OnResume();        cameraView.OnResume();    }
    protected override void OnPause()    {        base.OnPause();        cameraView.OnPause();    }
    public void OnCameraOpened()    {        cameraView.PostDelayed(delegate        {            cameraView.UseFlash(flashEnabled);            cameraView.ContinuousFocus();        }, 300);    }}
// Parsing results:
class BarcodeResultDelegate : BarcodeDetectorFrameHandler.BarcodeResultHandler{    public override bool Handle(FrameHandlerResult p0)    {        var success = (FrameHandlerResult.Success)p0;        if (success != null && success.Value != null)        {            var value = (BarcodeScanningResult)success.Value;            return true;        }
        return false;    }}
// Handling picture taken:
class PictureCallbackDelegate : PictureCallback{    public EventHandler<PictureCallbackEventArgs> OnPictureTakenHandler;
    public override void OnPictureTaken(byte[] image, int imageOrientation)    {        // Picture taken, process result    }}

Barcode Formats#

The Scanbot Barcode Scanner SDK supports various barcode formats:

1D Barcodes#

  • BarcodeFormat.Code39
  • BarcodeFormat.Code93
  • BarcodeFormat.Code128
  • BarcodeFormat.Codabar
  • BarcodeFormat.UpcA
  • BarcodeFormat.UpcE
  • BarcodeFormat.Ean8
  • BarcodeFormat.Ean13
  • BarcodeFormat.Itf
  • BarcodeFormat.MsiPlessey

2D Barcodes#

  • BarcodeFormat.QrCode
  • BarcodeFormat.Aztec
  • BarcodeFormat.Pdf417
  • BarcodeFormat.DataMatrix

Out of these, you can also filter which formats you wish to accept or not.

var configuration = new BarcodeScannerConfiguration();configuration.AcceptedFormats = new List<BarcodeFormat>{    BarcodeFormat.QrCode, BarcodeFormat.Aztec};

Detecting on Existing Images#

Not only can you scan barcodes, the SDK also offers the option to detect barcodes on an existing still image (e.g. JPG file from Photo Library).

List<Barcode> barcodes = await SBSDK.Operations.DetectBarcodesFrom(source);