安卓/ZXing不再有效。

4
我的应用程序使用ZXing条形码扫描器,使用ZXing帮助类IntentIntegrator和IntentResult。
现在我发现从ZXing提交的扫描结果不再存在,相关返回值为空/ null。
因此,我更新了最新的辅助类http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.javahttp://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentResult.java 现在我的onActivityResult方法在ZXing启动后立即调用 - 当然又是一个空结果。
我的代码非常简单,扫描是这样开始的:
  if (v==scanButton)
  {
     com.google.zxing.integration.android.IntentIntegrator integrator = new IntentIntegrator(this);
     integrator.initiateScan();
  }

并通过以下方式获取结果:
public void onActivityResult(int requestCode, int resultCode, Intent intent) 
{
  com.google.zxing.integration.android.IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
  if (scanResult != null) 
  {
     String format;

     format=scanResult.getFormatName();
     if ((format!=null) && (format.length()>0))
     {
         if ((format.equals("EAN_8")) || (format.equals("EAN_13")) ||(format.equals("UPC_A")) ||(format.equals("UPC_E")))
          getEANData(scanResult.getContents());
     }   
 }
}    

我在我的安卓设备上安装了最新的ZXing代码。为什么它现在不能正常工作了呢?

1个回答

1
从我目前的了解来看,这似乎是一个与安装有关的问题。在我的Android设备上,我可以看到这个问题,但它无法重现,我的应用程序的其他用户没有遇到这个问题。ZXing代码本身已经很长时间没有更改了,用户也确认它可以正常工作 - 所以这似乎是一个非常丑陋的错误。
在Playstore中安装的ZXing代码出现了这个问题,还没有测试过使用我的应用程序中包含的ZXing代码...

整合和意图代码已经有一段时间没有更改了,对我来说它运行良好。如果您仍然认为存在问题,您需要提供更多信息。我怀疑有一个流氓应用程序拦截了绑定到条形码扫描器的意图。 - Sean Owen
1
我不能说更多了:这段代码在我的机器上运行良好,没有问题。最近我再次测试了同样的应用程序,发现IntentResult没有返回任何内容。因此,我更新了IntentIntegrator/IntentResult到最新版本,在这里发现Intent立即返回而没有内容,而ZXing仍在运行。其他使用完全相同的应用程序的人没有遇到这些问题 - 那么我还能测试什么? - Elmi
@Elmi,我也遇到了同样的问题,你找到解决方案了吗? - Lisa Anne
@Lisa Anne:我记不太清了,但是在我的应用程序清单中有一个选项,它对使用的外部意图产生了影响 - 它们已经从主应用程序中解耦,因此无法正确地返回其结果... - Elmi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接