0

I have added core jar file of ZXing according to post Integrating the ZXing library directly into my Android application

in my application i'm trying to create an intent that starts the QR reader according to post QR code scanner

But i can not find the CaptureActivity class in the core.jar?

How can I read QR code within my application without using any external application?

Thanks, Eyal.

Community
  • 1
  • 1
eyal
  • 2,379
  • 7
  • 40
  • 54

2 Answers2

2

CaptureActivity should be there, it's just that you still have to add it to AndroidManifest.xml if you want to run it because that won't carry over from the jar. Add this XML

<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
  <action android:name="com.google.zxing.client.android.SCAN"/>
  <category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

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

(Yes, I have tried this myself)

also make sure you have

<uses-permission android:name="android.permission.CAMERA"/>
Thomas Dignan
  • 7,052
  • 3
  • 40
  • 48
  • Hi. Thanks for your reply. I have tried to add it in the imports section of my class and it failed to find it. – eyal Oct 10 '11 at 14:27
  • CaptureActivity is not in core.jar. It is part of android/, which should not be being copied. – Sean Owen Oct 10 '11 at 16:36
2

You're doing everything right -- except that you should not be using CaptureActivity. It's not found since it's not part of the core/ library, but rather part of android/, which is the source for our app, Barcode Scanner. I'd suggest not reusing our code quite that directly, since you will have to copy a lot to get it to work, and most people who go this route just copy nearly everything, and that's not OK.

You need to write your own application. See how the code in android/ calls the core library for decoding in DecodeHandler. You can look at our AndroidManifest.xml to see how to declare your intents. You do not need to, and should not, copy our CaptureActivity. It's there for good ideas, not cloning.

Sean Owen
  • 66,182
  • 23
  • 141
  • 173
  • You can check off "is library" in the project preferences of zxing as long as it is in your workspace, and then link to it from your other project. Once you have made this association (and added it to the AndroidManfest.xml of your other project) it will work. There is no need to rewrite your own CaptureActivity. I've had this working before. – Thomas Dignan Oct 12 '11 at 20:44