在我的Android应用程序上使用zxing扫描仪时出错

时间:2014-09-02 07:11:53

标签: android zxing barcode-scanner

我正在开发一个Android应用程序,我的主类代码是这样的。

但它在启动相机前显示错误。我该如何解决这个问题?

 public void onClick(View view) {
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_FORMATS", "CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF,CODABAR");
            startActivityForResult(intent, 0);    //Barcode Scanner to scan for us
        }
    });

这是我的STACKTRACE

09-02 13:54:51.659  20660-20660/com.mehdi.BarCodeScanner I/ViewRootImpl﹕ ViewRoot's Touch Event : Touch Down
09-02 13:54:51.739  20660-20660/com.mehdi.BarCodeScanner I/ViewRootImpl﹕ ViewRoot's Touch Event : Touch UP
09-02 13:55:06.919  20660-20660/com.mehdi.BarCodeScanner D/AndroidRuntime﹕ Shutting down VM
09-02 13:55:06.919  20660-20660/com.mehdi.BarCodeScanner W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41813e48)
09-02 13:55:06.949  20660-20660/com.mehdi.BarCodeScanner E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.mehdi.BarCodeScanner, PID: 20660
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.SCAN }
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
        at android.app.Activity.startActivityForResult(Activity.java:3468)
        at android.app.Activity.startActivityForResult(Activity.java:3429)
        at com.mehdi.BarCodeScanner.main$2.onClick(main.java:106)
        at android.view.View.performClick(View.java:4442)
        at android.view.View$PerformClick.run(View.java:18473)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5105)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
        at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

  

android.content.ActivityNotFoundException:找不到处理Intent的活动{act = com.google.zxing.client.android.SCAN}

您需要先安装ZXing应用程序,然后再尝试通过Intent使用它。

考虑使用IntentIntegrator方法自动检查和安装ZXIng应用程序。