2017-02-21 146 views
1

(我非常感谢史蒂夫和CN1队),但发现了下面的代码。有提到的EAN13类型,所以条形码阅读器只能阅读EAN13条形码。我需要阅读imei no。这是我认为code_128或可能是code_39格式的移动设备。所以你可以让图书馆读取其他格式的条形码。三江源于读取条码QR码阅读器的lib只读取我所看到的只是史蒂夫修补的QR码阅读器库EAN13格式

if (qrCode) { 
     intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.QRCODE}); 
    } else { 
     intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.EAN13}); 
    } 

更新1:

scanBarButton.addActionListener(e -> { 
    Display.getInstance().setProperty("android.scanTypes", "CODE_39;CODE_93;CODE_128"); 
    QRScanner.scanBarCode(new ScanResult() { 
     public void scanCompleted(String contents, String formatName, byte[] rawBytes) { 
      imeiTextArea.setText(contents); 
     } 

     public void scanCanceled() { 
      Dialog.show("Cancelled", "Scan Cancelled", "OK", null); 
     } 

     public void scanError(int errorCode, String message) { 
      Dialog.show("Error", message, "OK", null); 
     } 

    }); 
}); 

回答

0

使用:

Display.getInstance()的setProperty( “android.scanTypes”, “CODE_128”);

可能值包括:

"UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128", "ITF", "RSS_14", "RSS_EXPANDED", "QR_CODE" & "DATA_MATRIX" 

通知您可以用分号如分离它支持多种类型:

Display.getInstance().setProperty("android.scanTypes", "CODE_128;CODE_93"); 
+0

我已经尝试过,但它只能读取这是在设置EAN_13上面的库代码。 PLZ看到上面的问题更新的代码... – beck

+0

我不知道你从哪里得到的代码? –

+0

这里的律猴QRScanner混帐 - https://github.com/littlemonkeyltd/QRScanner及其通过shannah新修补的lib了。 https://github.com/shannah/QRScanner – beck