public BarcodeScannerRenderer(Context context) : base(context) { MainLayout = (ConstraintLayout)LayoutInflater.FromContext(context).Inflate(Resource.Layout.BarcodeTracker, null); AddView(MainLayout); CameraSourcePreview = MainLayout.FindViewById <CameraSourcePreview>(Resource.Id.preview); CloseScannerButton = MainLayout.FindViewById <ImageButton>(Resource.Id.closeScannerBtn); CloseScannerButton.Click += async delegate { await Xamarin.Forms.Application.Current.MainPage.Navigation.PopModalAsync(); }; MGraphicOverlay = MainLayout.FindViewById <GraphicOverlay>(Resource.Id.faceOverlay); BarcodeDetector detector = new BarcodeDetector.Builder(Application.Context) .Build(); detector.SetProcessor( new MultiProcessor.Builder(new GraphicBarcodeTrackerFactory(MGraphicOverlay, this)).Build()); if (!detector.IsOperational) { // Note: The first time that an app using barcode API is installed on a device, GMS will // download a native library to the device in order to do detection. Usually this // completes before the app is run for the first time. But if that download has not yet // completed, then the above call will not detect any barcodes. // // IsOperational can be used to check if the required native library is currently // available. The detector will automatically become operational once the library // download completes on device. Android.Util.Log.Warn(TAG, "Barcode detector dependencies are not yet available."); } MCameraSource = new CameraSource.Builder(Application.Context, detector) .SetAutoFocusEnabled(true) .SetFacing(Android.Gms.Vision.CameraFacing.Back) .SetRequestedFps(15.0f) .Build(); var torchFab = FindViewById <FloatingActionButton>(Resource.Id.fab_torchlight); var hasFlashlight = Context.PackageManager.HasSystemFeature(PackageManager.FeatureCameraFlash); if (!hasFlashlight) { torchFab.Hide(); } else { torchFab.Click += TorchFab_Click; } StartCameraSource(); }