如何为条形码扫描器设置多种格式或排除一对?

How can I set many formats for barcode scanner or exclude couple?

此代码集扫描仪仅用于二维码:

mBarcodeDetector = new BarcodeDetector.Builder(mContext)
                    .setBarcodeFormats(Barcode.QR_CODE)
                    .build();

但我想要更多格式。

您可以select您需要的所有格式:

BarcodeDetector detector = new BarcodeDetector.Builder(getApplicationContext())
                    .setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE)
                    .build();

来自the doc

Bit mask (containing values like QR_CODE and so on) that selects which formats this barcode detector should recognize.

The full list of supported format constants is:

  • ALL_FORMATS
  • AZTEC
  • CODE_128
  • CODE_39
  • CODE_93
  • CODABAR
  • DATA_MATRIX
  • EAN_13
  • EAN_8
  • ITF
  • PDF417
  • QR_CODE
  • UPC_A
  • UPC_E

By default, the detector will recognize all supported formats. This corresponds to the special ALL_FORMATS constant.

Here您有一个使用移动视觉的条码检测示例API。