简体   繁体   English

ZXing.Net.Mobile扫描不会触发

[英]ZXing.Net.Mobile scan doesn't trigger

I'm currently trying to implement this compontent into my android application built with Xamarins mono for andriod. 我目前正在尝试将此组件实施到用Xamarins mono for andriod构建的android应用程序中。

I'm having this issue that I can't get any result returned back from the scanner.Scan(); 我遇到了这个问题,我无法从scanner.Scan();返回任何结果scanner.Scan(); method, the scanner starts and nothing happens?! 方法,扫描仪启动,什么都没发生?

So I've tried downloading the sample projects from github and when I try scanning barcodes using the sample code provided there it's the same problem. 因此,我尝试从github下载示例项目,当我尝试使用提供的示例代码扫描条形码时,同样存在问题。 It will not fire. 它不会开火。 Here is some of the code responsible for starting the scanner and handeling the result: 以下是负责启动扫描仪并处理结果的一些代码:

public async void ScanArticleNumber()
        {
            //Tell our scanner to use the default overlay
            scanner.UseCustomOverlay = false;

            //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!";

            //Start scanning
            var result = await scanner.Scan();

            HandleScanResult(result);
        }

void HandleScanResult(ZXing.Result result)
        {
            string msg = "";

            if (result != null && !string.IsNullOrEmpty(result.Text))
                msg = "Found Barcode: " + result.Text;
            else
                msg = "Scanning Canceled!";

            Activity.RunOnUiThread(() =>
            {
                Toast.MakeText(Activity.BaseContext, msg, ToastLength.Short).Show();
            });
        }

The code never reaches the HandleScanResult method even tho I'm shooting loads of barcodes with the camera. 即使我用相机拍摄大量条形码,代码也永远不会到达HandleScanResult方法。

Any ideas why? 有什么想法吗?

Problem was solved by downloadning the latest version of ZXing.Net.Mobile from Github and then running that sample project and taking the following dlls from the bin folder: 通过从Github下载最新版本的ZXing.Net.Mobile,然后运行该示例项目并从bin文件夹中获取以下dll,解决了该问题:

  • ZXing.Net.Mobile.dll ZXing.Net.Mobile.dll
  • zxing.monoandroid.dll zxing.monoandroid.dll
  • Xamarin.Android.Support.v4.dll Xamarin.Android.Support.v4.dll

I replaced my current ddls with these and it worked! 我用这些替换了当前的ddls,它起作用了! This is probably because I from first downloaded the dlls from xamarin components , the files was probably not up to date. 这可能是因为我最初是从xamarin组件下载dll的,文件可能不是最新的。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM