Zxing change the action intent
I added the Zxing library to my android app but there is a problem. When you already have a bar code scanne开发者_Python百科r installed it presents you with a popup. I don't want this to happen and changed the the action intent. This is working, but when I open my app for the first time and select the bar code scanner it crashes. When I open it for the second time everything works fine.
Can anybody please help me?
I've already answered this a few times on the mailing list. As I said, you need to pay attention to ActivityNotFoundException
.
09-27 16:52:54.046 E/AndroidRuntime( 4949): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {nl.everybodylikespenguins/com.google.zxing.client.android.HelpActivity}; have you declared this activity in your AndroidManifest.xml?
09-27 16:52:54.046 E/AndroidRuntime( 4949): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at android.app.Activity.startActivityForResult(Activity.java:2789)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at android.app.Activity.startActivity(Activity.java:2895)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at com.google.zxing.client.android.CaptureActivity.showHelpOnFirstLaunch(CaptureActivity.java:595)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:169)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-27 16:52:54.046 E/AndroidRuntime( 4949): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
Android throws this when you start an intent for which there is no app, and that's what's happening here. You need to handle this yourself by catching the exception and, maybe, sending the user to Market to download.
This is exactly what the code in android-integration
in zxing
does, which is why I also already told you to look at that.
精彩评论