Reputation: 881
I am trying to use zxing barcode inside one of my app to scan barcodes. I have used intent to start the barcode scanner on a button cick.
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
What I have found is that most barcode can scan fine but when I try to scan the ITF (Interleaved 2 of 5) barcode within my app it doesnt work but if I just use the zxing barcode scanner it works fine.
Now I have been searching for a while and have read that I can use ALLOWED_LENGTH. I couldnt find much information as to how to pass in this information to the scanner. I tried the following but its not really making any difference.
**int[] item = new int []{6, 7, 8, 9, 10, 11, 12, 13};**
**intent.putExtra("ALLOWED_LENGTHS", item);**
I added the two lines above to my code. Can someone please let me know what is the correct way to acheive this please.
Thanks in advance
Upvotes: 2
Views: 1362
Reputation: 10665
Solution
intent.putExtra("SCAN_MODE", Intents.Scan.ONE_D_MODE);
Note: You should probably use the provided intents, instead of hard-coding the extras string
Explanation
This has nothing to do with allowed lengths. ITF is not one of the PRODUCT_MODE formats
PRODUCT_FORMATS = EnumSet.of(BarcodeFormat.UPC_A,
BarcodeFormat.UPC_E,
BarcodeFormat.EAN_13,
BarcodeFormat.EAN_8,
BarcodeFormat.RSS_14,
BarcodeFormat.RSS_EXPANDED);
It is included in the list of 1D formats
ONE_D_FORMATS = EnumSet.of(BarcodeFormat.CODE_39,
BarcodeFormat.CODE_93,
BarcodeFormat.CODE_128,
BarcodeFormat.ITF,
BarcodeFormat.CODABAR);
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
changing your intent extra would enable ITF support, but might have other consequences (eg product search functionality)
Upvotes: 2