Blockquote
我从扫描仪得到一些时间“你好:)”或大部分时间是前一次扫描结果 . 假设我成功扫描了“ABC001”然后尝试扫描“XYZ001”,但结果是“ABC001”,即之前的扫描结果 . 我在下面分享了我的代码 . 请有人告诉我我做错了什么 . 我正在使用NuGet的ZXing.Net.Mobile最新版本2.4.1 . 谢谢
Blockquote
private MobileBarcodeScanner scanner;
private void StartScanning()
{
// Starting the inbuilt scanner to scann
View zxingOverlay;
MobileBarcodeScanner.Initialize(Application);
scanner = new MobileBarcodeScanner();
//Inflate our custom overlay from a resource layout
zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ScannerOverlay, null);
//Find the button from our resource layout and wire up the click event
var flashButton = zxingOverlay.FindViewById<Button>(Resource.Id.buttonZxingFlash);
flashButton.Click += (sender, e) => scanner.ToggleTorch();
scanner.UseCustomOverlay = true;
//Inflate our custom overlay from a resource layout
//Set our custom overlay
scanner.CustomOverlay = zxingOverlay;
//We can customize the top and bottom text of the default overlay
scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away";
scanner.BottomText = "Wait for the barcode to automatically scan!";
var opt = new MobileBarcodeScanningOptions();
opt.DelayBetweenContinuousScans = 3000;
//Start scanning
scanner.ScanContinuously(opt, HandleScanResult);
}
/*
* Handle the scanned Result
*/
private void HandleScanResult(ZXing.Result result)
{
if (!string.IsNullOrEmpty(result.Text))
{
this.RunOnUiThread(() => Toast.MakeText(this, result.Text), ToastLength.Short).Show());
}
else
{
this.RunOnUiThread(() => Toast.MakeText(this, "scanning failed"), ToastLength.Short).Show());
}
}