protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.FragmentActivity); scanFragment = new ZXingScannerFragment(result => { // Null result means scanning was cancelled if (result == null || string.IsNullOrEmpty(result.Text)) { Toast.MakeText(this, "Scanning Cancelled", ToastLength.Long).Show(); return; } // Otherwise, proceed with result }, new MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { ZXing.BarcodeFormat.All_1D }, CameraResolutionSelector = availableResolutions => { foreach (var ar in availableResolutions) { Console.WriteLine("Resolution: " + ar.Width + "x" + ar.Height); } return(null); } }); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); }
protected override void OnResume() { base.OnResume(); if (scanFragment == null) { var zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlayCustomScanArea, null); scanArea = zxingOverlay.FindViewById <View>(Resource.Id.scanView); //Find all the buttons and wire up their events buttonRectangle = zxingOverlay.FindViewById <Button>(Resource.Id.buttonSquareScanRectangle); buttonSquare = zxingOverlay.FindViewById <Button>(Resource.Id.buttonSquareScanView); scanViewPosition = zxingOverlay.FindViewById <ToggleButton>(Resource.Id.toggleButtonScanViewLocation); buttonIncrease = zxingOverlay.FindViewById <ImageButton>(Resource.Id.buttonIncrease); buttonDecrease = zxingOverlay.FindViewById <ImageButton>(Resource.Id.buttonDecrease); buttonRandom = zxingOverlay.FindViewById <Button>(Resource.Id.buttonRandom); buttonRectangle.Click += Rectangle_Click; buttonSquare.Click += Square_Click; scanViewPosition.Click += ScanViewPosition_Click; buttonIncrease.Click += ButtonIncrease_Click; buttonDecrease.Click += ButtonDecrease_Click; buttonRandom.Click += ButtonRandom_Click; scanFragment = new ZXingScannerFragment(zxingOverlay, true, scanArea); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); } Scan(); }
protected override void OnResume() { base.OnResume(); var needsPermissionRequest = ZXing.Net.Mobile.Android.PermissionsHandler.NeedsPermissionRequest(this); if (needsPermissionRequest) { ZXing.Net.Mobile.Android.PermissionsHandler.RequestPermissionsAsync(this); } if (scanFragment == null) { scanFragment = new ZXingScannerFragment(); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); } if (!needsPermissionRequest) { scan(); } }
protected override void OnResume() { base.OnResume(); if (scanFragment == null) { scanFragment = new CustomScannerFragment { BottomText = learningTask.Description }; SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); } bool needsPermission = PermissionsHandler.NeedsPermissionRequest(this); if (needsPermission) { PermissionsHandler.RequestPermissionsAsync(this); } else { scanFragment.StartScanning(OnScanResult, GetOptions()); } }
public Scanner(Android.App.Application app) { // MobileBarcodeScanner.Initialize(app); // m_scanner = new MobileBarcodeScanner(); // m_scanner.Dispatcher = dispatcher; // this is what they did in the sample -- don't know why its necessary... m_scannerControl = new ZXingScannerFragment(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.FragmentActivity); scanFragment = new ZXingScannerFragment(); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); zxingOverlay = LayoutInflater.FromContext(this.Activity).Inflate(Resource.Layout.ZxingOverlay, null); scanFragment = new ZXingScannerFragment(ScanResultCallback); scanFragment.UseCustomView = true; scanFragment.CustomOverlayView = zxingOverlay; this.Activity.SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); }
protected override void OnResume() { base.OnResume(); if (scanFragment == null) { scanFragment = new ZXingScannerFragment(); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, scanFragment) .Commit(); } Scan(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.IDView); _bottomSheet = FindViewById <LinearLayout>(Resource.Id.bottom_sheet); _scanner = new ZXingScannerFragment { ScanningOptions = MobileBarcodeScanningOptions.Default }; SupportFragmentManager.BeginTransaction() .Add(Resource.Id.ZXingScannerLayout, _scanner, "ZXINGSCANNER") .Commit(); BindCommands(); var v = this.FindViewById(Resource.Id.IDViewLayout); v.ClipToOutline = true; }
protected override async void OnResume() { base.OnResume(); //// if bluetooth is enabled fire off enable ble request (caught by the bluetooth reciever which will //// then turn on the bluetooth device if (_androidBluetoothManager.Adapter.IsEnabled) { DisableBluetooth(); } else { EnableBluetooth(); } // refresh browser //_webView.LoadUrl("javascript:window.location.reload(true)"); var needsPermissionRequest = ZXing.Net.Mobile.Android.PermissionsHandler.NeedsPermissionRequest(this); if (needsPermissionRequest) { await ZXing.Net.Mobile.Android.PermissionsHandler.RequestPermissionsAsync(this); } if (_scanFragment == null) { _scanFragment = new ZXingScannerFragment(); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.mainBarcodeScannerFrameLayout, _scanFragment) .Commit(); SupportFragmentManager.ExecutePendingTransactions(); } if (!needsPermissionRequest) { StartScanningForQRCode(); } }