How To Trigger Bulk Mode Scan using Zxing library for Xamarin cross platform?

Requirement: I would like to use zxing library in xamarin to scan multiple barcode at a time without closing the camera.

Problem : Currentely, if I scan the barcode using zxing then camera gets closed and need to do same process again for another barcode in xamarin.

Please add your thoughts on the same.


  • KertzKertz USMember

    Are you trying to do this on android or iOS ? I know this post is old but did you find way/ways on how to accomplish this?

  • Le-royStaines.7824Le-royStaines.7824 NZMember ✭✭✭

    This may not be the best way to do it; but here's how I did it:

    In ZXingScannerViewController.cs I commented out scannerView.StopScanning(); under ViewDidAppear...

            public override void ViewDidAppear (bool animated)
                scannerView.OnScannerSetupComplete += HandleOnScannerSetupComplete;
                originalStatusBarStyle = UIApplication.SharedApplication.StatusBarStyle;
                if (UIDevice.CurrentDevice.CheckSystemVersion (7, 0))
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.Default;
                    SetNeedsStatusBarAppearanceUpdate ();
                    UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.BlackTranslucent, false);
                Console.WriteLine("Starting to scan...");
                Task.Factory.StartNew (() =>
                    BeginInvokeOnMainThread(() => scannerView.StartScanning (this.ScanningOptions, result =>
                        Console.WriteLine ("Stopping scan...");
                        //scannerView.StopScanning ();
                        var evt = this.OnScannedResult;
                        if (evt != null)
                            evt (result);

    And under MobileBarcodeScanner.cs I added a new method that takes a callback function:

            public Boolean StartScanWithCallback(MobileBarcodeScanningOptions options,Func<String,Boolean> callbackFunction, bool useAVCaptureEngine) {
                Version sv = new Version (0, 0, 0);
                Version.TryParse (UIDevice.CurrentDevice.SystemVersion, out sv);
                var is7orgreater = sv.Major >= 7;
                var allRequestedFormatsSupported = true;
                if (useAVCaptureEngine)
                    allRequestedFormatsSupported = AVCaptureScannerView.SupportsAllRequestedBarcodeFormats(options.PossibleFormats);
                this.appController.InvokeOnMainThread(() => {
                    if (useAVCaptureEngine && is7orgreater && allRequestedFormatsSupported)
                        viewController = new AVCaptureScannerViewController(options, this);                         
                        if (useAVCaptureEngine && !is7orgreater)
                            Console.WriteLine("Not iOS 7 or greater, cannot use AVCapture for barcode decoding, using ZXing instead");
                        else if (useAVCaptureEngine && !allRequestedFormatsSupported)
                            Console.WriteLine("Not all requested barcode formats were supported by AVCapture, using ZXing instead");
                        viewController = new ZXing.Mobile.ZXingScannerViewController(options, this);
                    viewController.OnScannedResult += barcodeResult => {
                        if (barcodeResult != null) {
                            //var t1 = new Thread (() => {
                            Object thisLock = new object();
                            lock(thisLock) {
                            //t1.Start ();
                    appController.PresentViewController((UIViewController)viewController, false, null);
                return true;

    And lastly, to start scanning, I called:

    scanner.StartScanWithCallback (options, scanCallback, false);

    Where scanCallback is something like:

            // Handle the scan callback
            public Boolean scanCallback(String result) {
                // result = the QR text
  • jp0127lilyjp0127lily USMember ✭✭

    hi Le-royStaines.7824
    did we have the resource sample and thank you ?

Sign In or Register to comment.