0

I am trying to generate qrcode via intent, but I'm always getting ActivityNotFoundException. I have my core.jar in my lib.

Here is my code:

intent = new Intent("com.google.zxing.client.android.ENCODE");
    intent.putExtra("ENCODE_TYPE", "TEXT_TYPE");
    intent.putExtra("ENCODE_DATA", "Hello World!");
    startActivity(intent);

And here is the log:

10-12 20:47:09.457: E/AndroidRuntime(1347): FATAL EXCEPTION: main
10-12 20:47:09.457: E/AndroidRuntime(1347): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sampleqrcode/com.example.sampleqrcode.MainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.ENCODE cat=[android.intent.category.DEFAULT] (has extras) }
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.os.Looper.loop(Looper.java:137)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at java.lang.reflect.Method.invokeNative(Native Method)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at java.lang.reflect.Method.invoke(Method.java:511)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at dalvik.system.NativeStart.main(Native Method)
10-12 20:47:09.457: E/AndroidRuntime(1347): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.zxing.client.android.ENCODE cat=[android.intent.category.DEFAULT] (has extras) }
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.Activity.startActivityForResult(Activity.java:3190)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.Activity.startActivity(Activity.java:3297)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at com.example.sampleqrcode.MainActivity.onCreate(MainActivity.java:24)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.Activity.performCreate(Activity.java:4465)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
10-12 20:47:09.457: E/AndroidRuntime(1347):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
10-12 20:47:09.457: E/AndroidRuntime(1347):     ... 11 more

Am I missing something?

j0k
  • 22,600
  • 28
  • 79
  • 90

2 Answers2

0
  1. import a zxing library project in your workspace from here.

  2. create a new project from a library project.It will work fine.

    Also you can visit this link for implementation.

Community
  • 1
  • 1
AppMobiGurmeet
  • 719
  • 3
  • 6
0

This means that Barcode Scanner is not installed. You are responsible for catching ActivityNotFoundException and handling it, like prompting the user to install it.

Better still, use the android-integration code in the original zxing project. It's two classes, and it wraps up all of the details like this in a simple API. http://code.google.com/p/zxing/wiki/ScanningViaIntent

Sean Owen
  • 66,182
  • 23
  • 141
  • 173