Reputation: 767
I'm developing an app (for a single customer) with Xamarin that must read barcodes with the camera (and optionally with an external bluetooth scanner), and used for testing an Asus TF300T, a LG4xP880 and a Nexus 7 second edition (the target machine).
I tested ScandIt and ZXing, but the best results I had with the free Barcode Scanner app (same library of ZXing, I know, but can't get the same speed). I've read that I can use it with an intent, and I can also buy the plus version (need portrait scanning), but I couldn't find any documentation on how to (if possible), with intent call only:
Is it possible?
Upvotes: 0
Views: 4224
Reputation: 10685
ZXing provides an IntentIntegrator class that either launches ZXing or prompts the user to install it from the Google Play store. However, if you know Barcode Scanner or Barcode Scanner Plus is installed, you can just call StartActivityForResult
yourself. Here is a recipe using StartActivityForResult
The layout is determined by the orientation of the device, there is no need to specify it. However, as you are aware, ZXing only works in landscape, so you will need to buy the plus version for portrait support.
ZXing provides two options for specifying the barcodes to decode
intent.putExtra("SCAN_MODE", ...)
According to ZXing Intents scan mode can be one of PRODUCT_MODE
, ONE_D_MODE
, QR_CODE_MODE
or DATA_MATRIX_MODE
. Alternatively you can provide a list of formats you'd like to support for any given instance
intent.putExtra("SCAN_FORMATS", "EAN_13,EAN_8,QR_CODE,...")
The plus version was published by Sean Owen of the ZXing team and it based on ZXing, so it probably has identical configuration options and responds to the same intent.
Bonus: I wrote an app for external scanners that does the heavy lifting of connecting and configuring the scanner. It makes it trivial to add bluetooth barcode scanner support to any new or existing app. Think of it as ZXing for bluetooth barcode scanning. The client code is up on GitHub and provides instructions for getting started.
Upvotes: 1