I've been searching on how to add a barcode scanner to my app. Does anybody know of any examples or know how to do this easily? Any help is greatly appreciated.
+2
A:
Can you be more specific about what your application is like -- what language, desktop or mobile?
The code is open source and so provides example usage in J2ME, desktop Java, Blackberry, BUG, Android, iPhone: http://code.google.com/p/zxing/source/browse/trunk Just look at that for complete working examples.
See also:
Sean Owen
2010-01-12 16:31:01
The question title and tags mention Android, so I presume that it's mobile and Java the language.
Christopher
2010-01-12 20:06:02
Thanks guys! I'm a newbie android dev and really just wanted to start figuring out what it would take to get a bar code scanner to work. I still need to figure out how to even add com.google.zxing to my project. Is that as easy as just using com.google.zxing in my code or do I have to download the source and import it to my manifest file?
wajiw
2010-01-13 16:54:05
(I'm the project dev BTW -- we can continue at http://groups.google.com/group/zxing/) Christopher is right. By using code like that you don't need to import any project code at all. You are calling out to the Barcode Scanner app via Intent; no barcode scanning code in your app.
Sean Owen
2010-01-13 18:46:25
The really nice way to do it involves a little more code, which will make sure the user is cleanly prompted to install Barcode Scanner if necessary. That's the other link he referred to. Copy the class at http://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java and use that. Again no other code needed.If you want you can go all the way and embed the scanning code, but without a hard reason to do it, it's only harder for you.
Sean Owen
2010-01-13 18:47:36
That's exactly what I need. I'll hit the google group if I have any more questions. Thanks again!
wajiw
2010-01-13 19:27:27
So to use this IntentIntegrator I have to copy it into my project (in that case svn:externals might be a good idea to avoid keeping a stale version)?
obvio171
2010-04-11 18:05:27
Yes, you'd need to copy it (taking note of the Apache Licence requirements). Though it's so simple, I wouldn't bother with keeping up-to-date via svn:externals or anything.
Christopher
2010-04-11 21:55:12
+1
A:
Using the provided IntentInegrator is better. It allows you to prompt your user to install the barcode scanner if they do not have it. It also allows you to customize the messages. The IntentIntegrator.REQUEST_CODE constant holds the value of the request code for the onActivityResult to check for in the above if block.
IntentIntegrator.initiateScan(YourActivity);
Yack
2010-10-19 02:52:58