ZXing Result.getRawBytes(),究竟是什么?

我正在使用zxing QR代码API,我正在尝试从Android设备上的QR代码中提取二进制数据。 但是,在android上,Result.getResultMetadata()没有通过Intent传递给我,所以我尝试使用Result.getRawBytes()来检索我的字节数组。 但是,getRawBytes()似乎没有返回相同的东西。

究竟是什么Result.getRawBytes(),有谁知道如何从zxing QR码正确提取字节数组?

谢谢

所以我认为你想要的是字节数组中的原始解码数据。 zxing给你的意图源是缺少元数据,但它仍然被发送到intentfilter。

在IntentIntegrator.java中的parseActivityResult中,您可以添加:

 byte[] dataBytes = intent.getByteArrayExtra("SCAN_RESULT_BYTE_SEGMENTS_0"); return new IntentResult(contents, formatName, rawBytes, orientation, errorCorrectionLevel, dataBytes); 

我修改了IntentResult类以便能够获取这个额外的部分:

 private final byte[] dataBytes; IntentResult() { this(null, null, null, null, null, null); } IntentResult(String contents, String formatName, byte[] rawBytes, Integer orientation, String errorCorrectionLevel, byte[] dataBytes) { this.contents = contents; this.formatName = formatName; this.rawBytes = rawBytes; this.orientation = orientation; this.errorCorrectionLevel = errorCorrectionLevel; this.dataBytes = dataBytes; } /** * @return raw content of barcode in bytes */ public byte [] getDataBytes() { return dataBytes; } 

此字节数组存储元数据的第一个数组,AKA是数据的原始内容(以字节为单位)。

为什么不从javadoc开始呢?

它是QR码中的原始码字。 它不是单独解析的字节段。