Java – Android Vision API – How to get barcode types for barcode detection?

Android Vision API – How to get barcode types for barcode detection?… here is a solution to the problem.

Android Vision API – How to get barcode types for barcode detection?

I

am using the Android Google Vision API and have created a standard barcode reader, but I want to detect the type/format of the barcode read, i.e. code 39,
CODE 128, QR Code…. etc
Return type anyway?

Thanks

Solution

Because I didn’t find any built-in function to decode Format integer value to text value
I used the following custom method

private String decodeFormat(int format) {
    switch (format){
        case Barcode.CODE_128:
            return "CODE_128";
        case Barcode.CODE_39:
            return "CODE_39";
        case Barcode.CODE_93:
            return "CODE_93";
        case Barcode.CODABAR:
            return "CODABAR";
        case Barcode.DATA_MATRIX:
            return "DATA_MATRIX";
        case Barcode.EAN_13:
            return "EAN_13";
        case Barcode.EAN_8:
            return "EAN_8";
        case Barcode.ITF:
            return "ITF";
        case Barcode.QR_CODE:
            return "QR_CODE";
        case Barcode.UPC_A:
            return "UPC_A";
        case Barcode.UPC_E:
            return "UPC_E";
        case Barcode.PDF417:
            return "PDF417";
        case Barcode.AZTEC:
            return "AZTEC";
        default:
            return "";
    }
}

Related Problems and Solutions