How to write a barcode scanner in Android using zxing

佐手、 提交于 2019-12-23 05:28:03

问题


I want to integrate bar-code scannerin my Android application.

I attempted to add the zxing library, but all my app does is show the camera view without scanning.

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

Is there a simple way to integrate barcode scanning functionality?


回答1:


This is waaaay too open-ended of a question. Long and short of it is that the Android app parts of ZXing are a bit monolithic and can be hard to copy into your existing app unless you're very familiar with it -- I'd actually suggest starting from the ZXing source and getting that up and running, then hacking out the parts you don't need and adding your apps code into ZXing, rather than the other way around (changing the package names and such, adding your activities to the manifest, etc.).

The key code you'll want to start changing is in CaptureActivity.java's handleDecode/handleDecodeInternally methods; that's what gets called when the scanner picks up a valid barcode.

Once you're more familiar with the source, you might try putting all the core zxing classes in a JAR file, since you'll rarely need to touch those and they operate reasonably independently of the Android app parts (since they're shared with the other non-Android Java zxing versions).

Also, be sure to weigh the inconvenience of having to maintain your ZXing code whenever a buggy new device comes out -- the ZXing guys do that work for you automatically if you just integrate via the Intents instead of copy-pasting their code.



来源:https://stackoverflow.com/questions/6494683/how-to-write-a-barcode-scanner-in-android-using-zxing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!