protected void SetScanState(ScanState state, IScanSession scanSession) { scanState = state; switch (state) { case ScanState.STOPPED: if (scanSession != null) { scanSession.StopScanning(); } else { picker.StopScanning(); } break; case ScanState.SCANNING: if (HasCameraPermission()) { picker.StartScanning(); } else { RequestCameraPermission(); } break; } }
public override void DidScan(BarcodePicker picker, IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { if (!ContinuousAfterScan) { // Stop the scanner directly on the session. session.PauseScanning(); } // If you want to edit something in the view hierarchy make sure to run it on the UI thread. UIApplication.SharedApplication.InvokeOnMainThread(() => { var symbologies = ""; var data = ""; foreach (var code in session.NewlyRecognizedCodes) { var separator = symbologies.Length == 0 ? "" : ", "; symbologies += separator + code.SymbologyString; data += separator + code.Data; } PickerView.DidScan(symbologies, data); }); } }
public void DidScan(IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { if (!ContinuousAfterScan) { // Call GC.Collect() before stopping the scanner as the garbage collector for some reason does not // collect objects without references asap but waits for a long time until finally collecting them. GC.Collect(); // Stop the scanner directly on the session. session.PauseScanning(); } // If you want to edit something in the view hierarchy make sure to run it on the UI thread. using (var h = new Android.OS.Handler(Android.OS.Looper.MainLooper)) { h.Post(() => { var symbologies = ""; var data = ""; foreach (var code in session.NewlyRecognizedCodes) { var separator = symbologies.Length == 0 ? "" : ", "; symbologies += separator + code.SymbologyName; data += separator + code.Data; } PickerView.DidScan(symbologies, data); }); } } }
public void DidScan(IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { Barcode code = session.NewlyRecognizedCodes [0]; Console.WriteLine("barcode scanned: {0}, '{1}'", code.SymbologyName, code.Data); // Mesmo problema no Garbage Collector lá de cima GC.Collect(); // Para de escanear na própria sessão session.StopScanning(); //Edição da UI, NÃO MEXER, DA ÚLTIMA VEZ DEU MERDA RunOnUiThread(() => { AlertDialog alert = new AlertDialog.Builder(this) .SetTitle(code.SymbologyName + " Barcode Detected") .SetMessage(code.Data) .SetPositiveButton("OK", delegate { barcodePicker.StartScanning(); }) .SetOnCancelListener(this) .Create(); alert.Show(); }); } }
public void DidScan(IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { Barcode code = session.NewlyRecognizedCodes [0]; Console.WriteLine("Código escaneado: {0}, '{1}'", code.SymbologyName, code.Data); // Call GC.Collect() before stopping the scanner as the garbage collector for some reason does not // collect objects without references asap but waits for a long time until finally collecting them. GC.Collect(); // Stop the scanner directly on the session. session.StopScanning(); // If you want to edit something in the view hierarchy make sure to run it on the UI thread. RunOnUiThread(() => { AlertDialog alert = new AlertDialog.Builder(this) .SetTitle(code.SymbologyName + " Código de barras detectado") .SetMessage(code.Data) .SetPositiveButton("OK", delegate { picker.StartScanning(); }) .SetOnCancelListener(this) .Create(); alert.Show(); }); } }
public override void DidScan(BarcodePicker picker, IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { Barcode code = session.NewlyRecognizedCodes.GetItem <Barcode> (0); Console.WriteLine("barcode scanned: {0}, '{1}'", code.SymbologyString, code.Data); // Stop the scanner directly on the session. session.StopScanning(); // If you want to edit something in the view hierarchy make sure to run it on the UI thread. UIApplication.SharedApplication.InvokeOnMainThread(() => { UIAlertView alert = new UIAlertView() { Title = code.SymbologyString + " Barcode Detected", Message = "" + code.Data }; alert.AddButton("OK"); alert.Clicked += (object o, UIButtonEventArgs e) => { picker.StartScanning(); }; alert.Show(); }); } }
public void DidScan(IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { Barcode code = session.NewlyRecognizedCodes[0]; Console.WriteLine("barcode scanned: {0}, '{1}'", code.SymbologyName, code.Data); // Call GC.Collect() before stopping the scanner as the garbage collector for some reason does not // collect objects without references asap but waits for a long time until finally collecting them. GC.Collect(); // Stop the scanner directly on the session. session.StopScanning(); // If you want to edit something in the view hierarchy make sure to run it on the UI thread. /*RunOnUiThread (() => { * AlertDialog alert = new AlertDialog.Builder (this) * .SetTitle (code.SymbologyName + " Barcode Detected") * .SetMessage (code.Data) * .SetPositiveButton("OK", delegate { * barcodePicker.StartScanning (); * }) * .SetOnCancelListener(this) * .Create (); * alert.Show (); * });*/ Intent i = new Intent(this, typeof(MainActivity)); i.AddFlags(ActivityFlags.ReorderToFront); i.PutExtra("barcode", code.Data); this.StartActivity(i); } }
public void DidScan(IScanSession session) { StartTimer(); if (session.NewlyRecognizedCodes.Count > 0) { Message message = Message.Obtain(); message.What = SCAN; message.Obj = session.NewlyRecognizedCodes[0]; handler.SendMessage(message); } }
public void DidProcess(byte[] imageBuffer, int width, int height, IScanSession session) { foreach (TrackedBarcode code in session.TrackedCodes.Values) { if (code.Symbology == Barcode.SymbologyEan8) { session.RejectTrackedCode(code); } } // If you want to implement your own visualization of the code tracking, you should update // it in this callback. }
/// <summary> /// Picker did scan event /// </summary> /// <param name="scannedSession"></param> public void DidScan(IScanSession scannedSession) { //Adding bar code to barcode list var barcodeList = scannedSession?.AllRecognizedCodes; var barcode = barcodeList?.LastOrDefault()?.Data; //barcode = FormatBarcode(barcodeList?.LastOrDefault()); if (!string.IsNullOrWhiteSpace(barcode)) { _scannedBarcodes.Add(barcode); } //invoke command _scanedItCamera?.DidScannedCommand?.Execute(_scannedBarcodes); }
public void DidScan(IScanSession session) { if (session.NewlyRecognizedCodes.Count > 0) { Barcode code = session.NewlyRecognizedCodes[0]; Console.WriteLine("barcode scanned: {0}, '{1}'", code.SymbologyName, code.Data); GC.Collect(); session.StopScanning(); resultData = Int32.Parse(code.Data); string dataLink = "https://abinodh.github.io/Shopinator/" + resultData + ".png"; var uri = Android.Net.Uri.Parse(dataLink); var intent = new Intent(Intent.ActionView, uri); StartActivity(intent); } }
public void DidScan(IScanSession session) { // This callback acts the same as when not tracking and can be used for the events such as // when a code is newly recognized. Rejecting tracked codes has to be done in didProcess(). }
public override void DidCaptureImage(BarcodePicker picker, CMSampleBuffer frame, IScanSession session) { if (session.TrackedCodes != null) { // For each tracked codes in the last processed frame. foreach (TrackedBarcode code in session.TrackedCodes.Values) { // As an example, let's visually reject all EAN8 codes. if (code.Symbology == Symbology.EAN8) { session.RejectTrackedCode(code); } } // If you want to implement your own visualization of the code matrix scan, // you should update it in this callback. } frame.Dispose(); }
public override void DidScan(BarcodePicker picker, IScanSession session) { // This delegate method acts the same as when not in matrix scan and can be used for the events such as // when a code is newly recognized. Rejecting tracked codes has to be done in barcodePicker(_:didProcessFrame:session:). }