ZXing.Mobile.MobileBarcodeScanner.Cancel() not working

PanayiotisZinierisPanayiotisZinieris USMember ✭✭
edited July 2016 in Xamarin.Forms

I'm developing a mobile application on Xamarin Forms for UWP, Android and IOS on Visual Studio.

I'm currently testing the app on my computer(Windows 10) and my phone (also Windows 10).

I'm using Zxing MobileBarcodeScanner to scan multiple barcodes.

When i press the back button i call the MobileBarcodeScanner.Cancel().

The only thing that it does is to close the camera. It doesn't depose the MobileBarcodeScanner's UI and i didn't found any solution for that.

Can anyone help me or suggest a solution?

Also the Cancel Button and the Flash Button aren't shown to the scanner UI.

Code:

private void showScanner()
{
var scanner = new MobileBarcodeScanner(App.coreDispatcher)
{
UseCustomOverlay = false,
TopText = "Hold camera up to barcode to scan",
BottomText = "Barcode will automatically scan",
CancelButtonText = "Done",
FlashButtonText = "Flash"
}

var opt = new MobileBarcodeScanningOptions { DelayBetweenContinuousScans = 3000 };

scanner.ScanContinuously(opt, HandleScanResult);

}

protected override bool OnBackButtonPressed()
{
scanner.Cancel();
}

private void HandleScanResult(ZXing.Result result)
{
string msg;
if (result != null && !string.IsNullOrEmpty(result.Text)) // Success
{
msg = result.Text;
}
else // Canceled
{
msg = "Scanning Canceled!";
}
}

Sign In or Register to comment.