protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); if (_view == null) { var activity = Context as Activity; _view = activity.LayoutInflater.Inflate(Resource.Layout.MrzLayout, this, false); AddView(_view); _scanView = _view.FindViewById <MrzScanView>(Resource.Id.mrz_scan_view); _scanView.InitAnyline(_licenseKey, this); _scanView.SetConfigFromAsset("MrzConfig.json"); // The config can be changed via code directly through the Config property, for example: var config = _scanView.Config; config.SetFlashMode(AnylineViewConfig.FlashMode.Auto); _scanView.Config.SetFlashAlignment(AnylineViewConfig.FlashAlignment.TopRight); // Important: Once the config is changed, it has to be set again explicitly: _scanView.Config = config; _scanView.SetCancelOnResult(false); _scanView.StartScanning(); _scanView.CameraOpened += _scanView_CameraOpened; } }
protected override void OnCreate(Bundle bundle) { Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn); base.OnCreate(bundle); ActionBar.SetHomeButtonEnabled(true); ActionBar.SetDisplayHomeAsUpEnabled(true); SetContentView(Resource.Layout.MrzActivity); SetTitle(Resource.String.scan_mrz); _scanView = FindViewById <MrzScanView>(Resource.Id.mrz_scan_view); _resultView = FindViewById <MrzResultView>(Resource.Id.mrz_result); _resultView.SetOnClickListener(this); _scanView.SetConfigFromAsset("MrzConfig.json"); _scanView.InitAnyline(MainActivity.LicenseKey, this); _scanView.SetCancelOnResult(true); _scanView.CameraOpened += (s, e) => { Log.Debug(TAG, "Camera opened successfully. Frame resolution " + e.Width + " x " + e.Height); _resultView.Visibility = ViewStates.Invisible; _scanView.StartScanning(); }; _scanView.CameraError += (s, e) => { Log.Error(TAG, "OnCameraError: " + e.Event.Message); }; }