vivek tiwari
vivek tiwari

Reputation: 645

Getting Error in Barcode Scanner in android

I am making a application using QR code scanner via ZXIng IntentIntegrator. I am able to make it using following code

IntentIntegrator integrator = new IntentIntegrator(
                        HomeActivity.this);
                integrator.initiateScan();


public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(
                requestCode, resultCode, intent);
        if (scanResult != null) {
            // handle scan result

            Toast.makeText(getApplicationContext(),
                    "scan   " + scanResult.getContents(), 1).show();
        }
        // else continue with any other code you need in the method

    }

And it run on real device. But when i try to run it on my other device(Samsung note 2). it gives me crash log.

03-06 19:10:19.940: E/AndroidRuntime(10325): FATAL EXCEPTION: main
03-06 19:10:19.940: E/AndroidRuntime(10325): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.aztecbarcodereader.zxing.client.android.SCAN cat=[android.intent.category.DEFAULT] flg=0x4080000 }
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1580)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.app.Activity.startActivityForResult(Activity.java:3446)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.app.Activity.startActivityForResult(Activity.java:3407)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at com.aztecbarcodereader.zxing.integration.android.IntentIntegrator.startActivityForResult(IntentIntegrator.java:290)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at com.aztecbarcodereader.zxing.integration.android.IntentIntegrator.initiateScan(IntentIntegrator.java:274)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at com.aztecbarcodereader.zxing.integration.android.IntentIntegrator.initiateScan(IntentIntegrator.java:209)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at com.raa.jwelarydemo.HomeActivity$8.onClick(HomeActivity.java:241)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.view.View.performClick(View.java:4223)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.view.View$PerformClick.run(View.java:17275)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.os.Handler.handleCallback(Handler.java:615)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.os.Looper.loop(Looper.java:137)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at android.app.ActivityThread.main(ActivityThread.java:4898)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at java.lang.reflect.Method.invokeNative(Native Method)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at java.lang.reflect.Method.invoke(Method.java:511)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
03-06 19:10:19.940: E/AndroidRuntime(10325):    at dalvik.system.NativeStart.main(Native Method)

Why am I getting this exception?

One more thing when I try any market app on this device to use barcode it also have same problem. I think I have to make some setting on my particular device. But I can't find a solution.

Upvotes: 0

Views: 1423

Answers (1)

FoamyGuy
FoamyGuy

Reputation: 46846

Where did you get the jar file that you are using? It seems as if it is not the official ZXing one.

Notice the action on your intent

com.aztecbarcodereader.zxing.client.android.SCAN

this does not match the action string that the official ZXing app uses, here is the real one:

com.google.zxing.client.android.SCAN

If you modified the IntentIntegrator.java file then you need to revert the changes and use the original source code. If you did not modify it then you need to go back to the official ZXing site and download a fresh copy of it, because the one you have appears to have been made(incorrectly) by someone else.

You can download the official one here: https://code.google.com/p/zxing/downloads/detail?name=ZXing-2.1.zip once you get the zip file open it up and inside the android-integration are the jarfiles that you need.

Upvotes: 2

Related Questions