Reputation: 2770
With Zxing lib, I'm able to scan QR code efficiently, bot I'm not able to scan Barcode scanning. I did lots of RnD and different different piece of code tested, but not workig.
So, My question -
is Zxing libs supports Barcode scanning in Android ?
If supports, should I use different zxing lib or same lib (QR_Code) lib will work ?
Any pointer/suggestion please.
Zxing lib Supported code -
List of barcode formats supported by ZXING
1. QR_CODE
2. DATA_MATRIX
3. UPC_E
4. UPC_A
5. EAN_8
6. EAN_13
7. UPC_EAN_EXTENSION
8. CODE_128
9. CODE_39
10. CODE_93 11. CODABAR 12. ITF 13. RSS14 14. PDF417 15. RSS_EXPANDED
Used code snapshot -
Option 1 -
Intent objIntent = new Intent("com.google.zxing.client.android.SCAN");
objIntent.putExtra("SCAN_MODE", "QR_CODE_MODE");
objIntent.putExtra("SCAN_FORMATS", "CODABAR");
startActivityForResult(objIntent, 0);
Option 2 -
Intent objIntent = new Intent("com.google.zxing.client.android.SCAN");
objIntent.putExtra("SCAN_MODE", "PRODUCT_MODE"");
objIntent.putExtra("SCAN_FORMATS", "UPC_A");
startActivityForResult(objIntent, 0);
Option 3 -
Intent objIntent = new Intent("com.google.zxing.client.android.SCAN");
objIntent.putExtra("SCAN_MODE", "PRODUCT_MODE"");
objIntent.putExtra("SCAN_FORMATS", "UPC_A");
startActivityForResult(objIntent, 0);
Option 4 -
Intent objIntent = new Intent("com.google.zxing.client.android.SCAN");
objIntent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(objIntent, 0);
I'm interested to scan only barcode not QR code -
Upvotes: 2
Views: 7497
Reputation: 2178
ZXing supports many barcode formats: UPC_A, UPC_E, EAN_8, EAN_13, CODE_39, CODE_93, CODE_128, and more.
The simplest way to use ZXing is with the android-integration they provide, it's also the way they want people to use it. I have an example project on github which shows how to use ZXing this way. Essentially you'll need to do something like this:
private void scanBarcode() {
IntentIntegrator integrator = new IntentIntegrator(getActivity());
Collection<String> BARCODE_TYPES =
Collections.unmodifiableCollection(Arrays.asList("UPC_A", "EAN_8", "EAN_13"));
integrator.initiateScan(BARCODE_TYPES);
}
If you want to use it directly then it would be best to checkout their code from github. From what I recall it is the CaptureActivity that you want to start.
It is also worth checkout out ZBar.
Upvotes: 0
Reputation: 8473
Why don't you go for Zbar library, that seems more easy to implement. Yes But if you want like Zxing's customized camera scanner you'll have to customize the surface of scanner camera otherwise, it'll fulfil you're requirement.
Here is the link for library with a sample too.
If you'll look to the sample , you can see there are two functions , one is for scanning both qr as well bar code. and other is for only qr code.
// This will scan both
public void launchScanner(View v) {
if (isCameraAvailable()) {
Intent intent = new Intent(this, ZBarScannerActivity.class);
startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
} else {
Toast.makeText(this, "Rear Facing Camera Unavailable", Toast.LENGTH_SHORT).show();
}
}
//this will scan only qr code
public void launchQRScanner(View v) {
if (isCameraAvailable()) {
Intent intent = new Intent(this, ZBarScannerActivity.class);
intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE});
startActivityForResult(intent, ZBAR_SCANNER_REQUEST);
} else {
Toast.makeText(this, "Rear Facing Camera Unavailable", Toast.LENGTH_SHORT).show();
}
}
Use As per your need.
Following barcodes are supported by Zbar :
PARTIAL, EAN8, UPCEISBN10, UPCA, EAN13, ISBN13, I25, DATABAR, DATABAR_EXP, CODABAR, CODE39 PDF417, QRCODE, CODE93, CODE128 .
Upvotes: 0