user1096447
user1096447

Reputation: 429

android zxing integration

Im trying to integrate zxing barcode scanner into my app. I am not wanting to do it via an intent as i would like the app to be an all in one solution. I understand the limitations this has but i dont really have an option on this one

i have followed the following guide to integrate the code as a library into my project

http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/

I am receiving a Null exception error with the following logcat . If anyone knows much about the zxing code could give me any pointers that would be great. let me know if you require any more background info

. I am calling the scaner with the following

        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
    startActivityForResult(intent, 0);



12-28 06:41:57.464: W/dalvikvm(4301): threadid=3: thread exiting with uncaught exception (group=0x2aaca450)
12-28 06:41:57.464: E/AndroidRuntime(4301): Uncaught handler: thread main exiting due to uncaught exception
12-28 06:41:57.504: E/AndroidRuntime(4301): java.lang.RuntimeException: Unable to resume activity {com.discovery_scan.app/com.google.zxing.client.android.CaptureActivity}: java.lang.NullPointerException
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2950)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2516)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.os.Looper.loop(Looper.java:123)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread.main(ActivityThread.java:4363)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at java.lang.reflect.Method.invokeNative(Native Method)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at java.lang.reflect.Method.invoke(Method.java:521)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:885)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:643)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at dalvik.system.NativeStart.main(Native Method)
12-28 06:41:57.504: E/AndroidRuntime(4301): Caused by: java.lang.NullPointerException
12-28 06:41:57.504: E/AndroidRuntime(4301):     at com.google.zxing.client.android.CaptureActivity.onResume(CaptureActivity.java:178)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.Activity.performResume(Activity.java:3763)
12-28 06:41:57.504: E/AndroidRuntime(4301):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2937)

Upvotes: 1

Views: 3462

Answers (1)

Sean Owen
Sean Owen

Reputation: 66891

The biggest confusion here is that you are trying to not use Intents, but, you are using Intents. Which is it?

I assume you are not actually wanting to use Intents. The error comes because you have copied and pasted our code without understanding it. I am sure it is because the onResume() method refers to UI elements that are not found in your copy of the layout.

Please don't copy our code like this; in fact a complete copy violates trademark, I think. Integrate via Intent if you don't have the time or inclination to write your own scanner app.

http://code.google.com/p/zxing/wiki/ScanningViaIntent

Upvotes: 2

Related Questions