diff --git a/Samples/Forms/Core/CustomScanPage.cs b/Samples/Forms/Core/CustomScanPage.cs index d7f990cc6..0476b3705 100644 --- a/Samples/Forms/Core/CustomScanPage.cs +++ b/Samples/Forms/Core/CustomScanPage.cs @@ -31,7 +31,7 @@ public CustomScanPage () : base () await DisplayAlert ("Scanned Barcode", result.Text, "OK"); // Navigate away - await Navigation.PopAsync (); + //await Navigation.PopAsync (); }); overlay = new ZXingDefaultOverlay @@ -49,8 +49,42 @@ public CustomScanPage () : base () VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; + + var stopButton = new Button + { + WidthRequest = 100, + HeightRequest = 50, + HorizontalOptions = LayoutOptions.Start, + VerticalOptions = LayoutOptions.End, + Text = "disable", + Command = new Command(() => zxing.IsScanning=false) + }; + + var cancelButton = new Button + { + WidthRequest = 100, + HeightRequest = 50, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.End, + Text = "cancel", + Command = new Command(async () => await Navigation.PopAsync()) + }; + + var startButton = new Button + { + WidthRequest = 100, + HeightRequest = 50, + HorizontalOptions = LayoutOptions.End, + VerticalOptions = LayoutOptions.End, + Text = "enable", + Command = new Command(() => zxing.IsScanning = true) + }; + grid.Children.Add(zxing); grid.Children.Add(overlay); + grid.Children.Add(startButton); + grid.Children.Add(cancelButton); + grid.Children.Add(stopButton); // The root page of your application Content = grid; diff --git a/Source/ZXing.Net.Mobile.Android/ZXingSurfaceView.cs b/Source/ZXing.Net.Mobile.Android/ZXingSurfaceView.cs index 6e4130a04..1f16f2766 100644 --- a/Source/ZXing.Net.Mobile.Android/ZXingSurfaceView.cs +++ b/Source/ZXing.Net.Mobile.Android/ZXingSurfaceView.cs @@ -98,6 +98,7 @@ public void AutoFocus(int x, int y) public void StartScanning(Action scanResultCallback, MobileBarcodeScanningOptions options = null) { + _cameraAnalyzer.SetupCamera(); ScanningOptions = options ?? MobileBarcodeScanningOptions.Default; _cameraAnalyzer.BarcodeFound += (sender, result) =>