Updated 27 November 2017
What is QR Code?
QR is an acronym for Quick Response. It’s a smarter version of the barcode, and it was originally developed in Japan for the automotive industry. Machines can read QR codes more quickly than barcodes, and QR codes can store more data in less space too.
Implementing QR Scanner by using ZXING Library- it provides easiest way to implement a QR code Scanner for developers.
following steps to use this library.
1 |
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3' |
onQRCodeReadListener
and let implements required methods or set a onQRCodeReadListener
to the QRCodeReaderView object.
1 2 3 4 |
<com.dlazaro66.qrcodereaderview.QRCodeReaderView android:id="@+id/qrdecoderview" android:layout_width="match_parent" android:layout_height="match_parent" /> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
public class QRDecoderActivity extends Activity implements OnQRCodeReadListener { private QRCodeReaderView qrCodeReaderView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_decoder); qrCodeReaderView = (QRCodeReaderView) findViewById(R.id.qrdecoderview); qrCodeReaderView.setOnQRCodeReadListener(this); // Use this function to enable/disable decoding qrCodeReaderView.setQRDecodingEnabled(true); // Use this function to change the autofocus interval (default is 5 secs) qrCodeReaderView.setAutofocusInterval(2000L); // Use this function to enable/disable Torch qrCodeReaderView.setTorchEnabled(true); // Use this function to set front camera preview qrCodeReaderView.setFrontCamera(); // Use this function to set back camera preview qrCodeReaderView.setBackCamera(); } // Called when a QR is decoded // "text" : the text encoded in QR // "points" : points where QR control points are placed in View @Override public void onQRCodeRead(String text, PointF[] points) { // add here your source code with scanning code } @Override protected void onResume() { super.onResume(); qrCodeReaderView.startCamera(); } @Override protected void onPause() { super.onPause(); qrCodeReaderView.stopCamera(); } } |
References: https://github.com/dlazaro66/QRCodeReaderView
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
@Override
public void onQRCodeRead(final String result, PointF[] points) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(ScanActivity.this, result, Toast.LENGTH_SHORT).show();
}
});
}
how to fix this error please help
https://uploads.disquscdn.com/images/55c7f6b5fce472a84b441397da4878134577c9ac373d38953805cc530c017cd1.png