4

In my app I want to scan a GS1-128 barcode, and need the FNC1 characters passed from the ZXing barcode scanner. Right now I just receive the plain text without the FNC1 characters.

Is there a way to pass the DecodeHintType.ASSUME_GS1 via Intent to the scanner app?

I don't want to include the complete scanner source in my app and rather use the Intent.

In the source code of the scanner I can see that the DecodeHintType needs to be set to achive that: https://code.google.com/p/zxing/source/browse/trunk/core/src/main/java/com/google/zxing/oned/Code128Reader.java

 boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1);

Thanks for any help. I searched almost the whole web and didn't find an answer to this. This is driving me nuts...

Terry Burton
  • 2,801
  • 1
  • 29
  • 41
Andreas H.
  • 161
  • 1
  • 9

2 Answers2

5

At the end it turned out that it was easier than I thought:

intentScan.putExtra("ASSUME_GS1", true);

The hints can be set with extras. I just had to figure it out, because I couldn't find it anywhere how to do that.

I downloaded the code of the Barcode Scanner and did a little debugging. But now I can use the original app and get the barcode via Intent. :-)

Andreas H.
  • 161
  • 1
  • 9
  • Hi, do you happen to know how to achieve this in the iOS / CPP version of the zing library? – Matthias Max Dec 04 '14 at 08:29
  • Ok, also you were scanning using intents. I have my iOS scanner running with GS1 recognition now on iOS. But in the app, not with intents.... – Matthias Max Dec 12 '14 at 21:00
  • In which file did you add that line of code? I'm trying to achieve the same for the data matrix reader and wanted to try that line there. However I can't find the intentScan variable inside the Code128Reader.java. – Matthias Max Dec 09 '15 at 12:28
  • @MatthiasMax `intentScan` variable is your intent, which you have to create e.g.: `Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");` – Jean Feb 04 '16 at 14:45
  • I used the scanning via Intent method described here: https://github.com/zxing/zxing/wiki/Scanning-Via-Intent you can add the line withing the initiateScan method. – Andreas H. Mar 09 '16 at 22:38
  • Another way to achieve this is `IntentIntegrator integrator = new IntentIntegrator(yourActivity); integrator.addExtra("ASSUME_GS1", true); integrator.initiateScan();` – enapi Jul 26 '17 at 11:25
  • How can I get FNC character from .Net library in Xamarin project? – dush88c Aug 06 '18 at 12:27
2

Yes, that's the hint you need. It will return FNC1 as ASCII 29. There's not a general way to pass the hints by Intent, but some are supported as additional Intent extras. If you want to submit a patch that triggers this hint I'll take a look.

Sean Owen
  • 66,182
  • 23
  • 141
  • 173
  • Hi Sean, thanks for your help. I figured it out now (check the answer below). So it looks like there is a certain way to pass the hints. BTW great product! :-) – Andreas H. Oct 18 '14 at 10:41
  • Hi @sean-owen I'm trying to add the ASSUME_GS1 hint to the data matrix reader with no luck. Where would I put the call inside the DataMatrixReader.java? – Matthias Max Dec 09 '15 at 12:29
  • I'm using the official phonegap barcodescanner which includes the zxing lib. However I believe it's way out of date, is this correct? It doesn't even have the ASSUME_GS1 flag defined: https://github.com/phonegap/phonegap-plugin-barcodescanner/blob/master/src/android/LibraryProject/src/com/google/zxing/DecodeHintType.java – Matthias Max Dec 09 '15 at 12:46
  • In other words: With your maintained version of zxing it is possible the see data matrix FNC1 identifer ]d2 ? Thanks for a quick tip! – Matthias Max Dec 09 '15 at 12:50