public final class BarcodeFormat

  1. Object
  2. BarcodeFormat

The normalized symbology names Barcode.getFormat() reports, as constants instead of literals. Every backend maps its own vendor identifier onto one of these before the result reaches application code, and reports UNKNOWN for a symbology outside this set.

scanner.process(VisionImage.encoded(jpeg)).ready(codes -> {
    for (Barcode code : codes) {
        if (BarcodeFormat.matches(code, BarcodeFormat.QR_CODE)) {
            Log.p("QR: " + code.getValue());
        } else if (BarcodeFormat.matches(code, BarcodeFormat.EAN_13,
                BarcodeFormat.UPC_A)) {
            lookUpProduct(code.getValue());
        }
    }
});

Fields

public static final String AZTEC = "AZTEC"Aztec two-dimensional code, common on transit tickets.
public static final String CODABAR = "CODABAR"Codabar linear code, used by libraries and blood banks.
public static final String CODE_39 = "CODE_39"Code 39 linear code.
public static final String CODE_93 = "CODE_93"Code 93 linear code.
public static final String CODE_128 = "CODE_128"Code 128 linear code, the usual choice for shipping labels.
public static final String DATA_MATRIX = "DATA_MATRIX"Data Matrix two-dimensional code, common on small parts.
public static final String EAN_8 = "EAN_8"EAN-8 retail product code.
public static final String EAN_13 = "EAN_13"EAN-13 retail product code.
public static final String ITF = "ITF"Interleaved 2 of 5 linear code.
public static final String PDF417 = "PDF417"PDF417 stacked code, used by driving licences and boarding passes.
public static final String QR_CODE = "QR_CODE"QR code.
public static final String UPC_A = "UPC_A"UPC-A retail product code.
public static final String UPC_E = "UPC_E"UPC-E retail product code.
public static final String UNKNOWN = "UNKNOWN"Reported when the backend decoded a code whose symbology has no portable name here.

Methods

public static boolean matches(Barcode barcode, String... formats)Tests a decoded barcode against a set of accepted formats.

Inherited methods

Field details

AZTEC

public static final String AZTEC = "AZTEC"
Aztec two-dimensional code, common on transit tickets.

CODABAR

public static final String CODABAR = "CODABAR"
Codabar linear code, used by libraries and blood banks.

CODE_39

public static final String CODE_39 = "CODE_39"
Code 39 linear code.

CODE_93

public static final String CODE_93 = "CODE_93"
Code 93 linear code.

CODE_128

public static final String CODE_128 = "CODE_128"
Code 128 linear code, the usual choice for shipping labels.

DATA_MATRIX

public static final String DATA_MATRIX = "DATA_MATRIX"
Data Matrix two-dimensional code, common on small parts.

EAN_8

public static final String EAN_8 = "EAN_8"
EAN-8 retail product code.

EAN_13

public static final String EAN_13 = "EAN_13"
EAN-13 retail product code.

ITF

public static final String ITF = "ITF"
Interleaved 2 of 5 linear code.

PDF417

public static final String PDF417 = "PDF417"
PDF417 stacked code, used by driving licences and boarding passes.

QR_CODE

public static final String QR_CODE = "QR_CODE"
QR code.

UPC_A

public static final String UPC_A = "UPC_A"
UPC-A retail product code.

UPC_E

public static final String UPC_E = "UPC_E"
UPC-E retail product code.

UNKNOWN

public static final String UNKNOWN = "UNKNOWN"
Reported when the backend decoded a code whose symbology has no portable name here.

Method details

matches

public static boolean matches(Barcode barcode, String... formats)
Tests a decoded barcode against a set of accepted formats. An empty or null format list accepts every symbology, which is what a general-purpose scanner wants.

Parameters

barcode Barcode
observation to test, or null
formats String...
accepted format constants

Returns

true when the barcode’s format is one of formats