Decoding a QR code in an Android app?

In Android, using ZXing , we can scan the QR code using the phone’s camera and decode it.

But, in my scenario, the image of the QR code is stored in the phone itself, and I need to decode it.

Is there a way to decode a QR image this way?

+1
java android zxing qr-code
source share
2 answers

You can use the ZXing code for this.

Check out DecodeHandler.java .

+3
source share

You can simply use the Mobile Vision API to decode a QR code with Image.It is very accurate and can detect more than one Qr code above an image.

To use the Mobile Vision API, you need to enable the following library:

compile 'com.google.android.gms: play-services-vision: 9.6.1'

BarcodeDetector detector = new BarcodeDetector.Builder(context) .setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE) .build(); if(!detector.isOperational()){ Log.d("QR_READ","Could not set up the detector!"); } Frame frame = new Frame.Builder().setBitmap(bitmap).build(); SparseArray<Barcode> barcodes = detector.detect(frame); Log.d("QR_READ","-barcodeLength-"+barcodes.size()); Barcode thisCode=null; if(barcodes.size()==0){ Log.d("QR_VALUE","--NODATA"); } else if(barcodes.size()==1){ thisCode = barcodes.valueAt(0); Log.d("QR_VALUE","--"+thisCode.rawValue); } else{ for(int iter=0;iter<barcodes.size();iter++) { thisCode = barcodes.valueAt(iter); Log.d("QR_VALUE","--"+thisCode.rawValue); } } 
+1
source share

All Articles