ZXing Barcode Scanner Intent: set DecodeHintType.ASSUME_GS1

你说的曾经没有我的故事 提交于 2019-11-28 05:04:39

问题


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...


回答1:


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. :-)




回答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.



来源:https://stackoverflow.com/questions/26390302/zxing-barcode-scanner-intent-set-decodehinttype-assume-gs1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!