【问题标题】:ZXing.Net.Mobile scan doesn't triggerZXing.Net.Mobile 扫描不触发
【发布时间】:2014-05-26 01:57:07
【问题描述】:

我目前正在尝试将this 组件实现到我用 Xamarins mono for andriod 构建的 android 应用程序中。

我遇到了这个问题,我无法从 scanner.Scan(); 方法返回任何结果,扫描仪启动并且没有任何反应?!

所以我尝试从github 下载示例项目,当我尝试使用那里提供的示例代码扫描条形码时,同样的问题。它不会着火。下面是一些负责启动扫描器和处理结果的代码:

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();
            });
        }

即使我用相机拍摄大量条形码,代码也永远不会到达 HandleScanResult 方法。

有什么想法吗?

【问题讨论】:

  • 也许是个愚蠢的问题,但您是通过模拟器还是通过连接的移动设备进行调试?扫描是否完成(但从未点击HandleScanResult) - 意思是,扫描仪 UI 是否关闭并将您返回到应用程序?
  • 我在移动设备上调试。什么都没有发生,这意味着在我关闭扫描仪之前我不会返回到应用程序。
  • 如果我没看错,听起来扫描仪永远不会捕获条形码。只是为了消除显而易见的问题,您是否已将相机权限添加到您的应用中?
  • 这些权限我已经添加了

标签: c# mono xamarin.android xamarin barcode-scanner


【解决方案1】:

Github下载最新版本的ZXing.Net.Mobile解决了问题 然后运行该示例项目并从 bin 文件夹中获取以下 dll:

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

我用这些替换了我当前的 ddls,它成功了!这可能是因为我一开始从xamarin components 下载了dll,文件可能不是最新的。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 2018-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-26
    相关资源
    最近更新 更多