开发者

How to write a barcode scanner in Android using zxing

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 scannin开发者_JS百科g.

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

Is there a simple way to integrate barcode scanning functionality?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜