我在应用程序中扫描条形码时遇到过这个问题,实际上,条形码旁边的某些产品上也存在QR码。所以zxing
也扫描QR码。
答案 0 :(得分:1)
public class QRScannerActivity extends Activity implements ZXingScannerView.ResultHandler {
// begin variable listing
private ZXingScannerView mScannerView;
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
mScannerView = new ZXingScannerView(this);
setContentView(mScannerView);
mScannerView.setFlash(true);
List<BarcodeFormat> myformat = new ArrayList<>();
myformat.add(BarcodeFormat.EAN_13);
myformat.add(BarcodeFormat.EAN_8);
myformat.add(BarcodeFormat.RSS_14);
myformat.add(BarcodeFormat.CODE_39);
myformat.add(BarcodeFormat.CODE_93);
myformat.add(BarcodeFormat.CODE_128);
myformat.add(BarcodeFormat.ITF);
myformat.add(BarcodeFormat.CODABAR);
myformat.add(BarcodeFormat.DATA_MATRIX);
myformat.add(BarcodeFormat.PDF_417);
mScannerView.setFormats(myformat);
// Programmatically initialize the scanner view
// Set the scanner view as the content view
}
@Override
public void onResume() {
super.onResume();
mScannerView.setResultHandler(this); // Register ourselves as a handler for scan results.
mScannerView.startCamera(); // Start camera on resume
}
@Override
public void onPause() {
super.onPause();
mScannerView.stopCamera(); // Stop camera on pause
}
@Override
public void handleResult(Result rawResult) {
// Do something with the result here
result=rawResult.getText();
Log.e("qr_Text1",result);
finish();
// Prints the scan format (qrcode, pdf417 etc.)
// If you would like to resume scanning, call this method below:
mScannerView.resumeCameraPreview(this);
}
}
编译&#39; me.dm7.barcodescanner:zxing:1.8.4&#39;