Qr Code Reader And Qr Code Generator for Android

In the first place QR code (abbreviated from Quick Response Code) is the trademark for a type of matrix barcode (or two-dimensional barcode). Not to mention it’s first designed for the automotive industry in Japan. On the other hand a barcode is a machine-readable optical label that contains information about the item to which it is attached. In fact a QR code uses four standardized encoding modes (numeric, alphanumeric, byte/binary, and kanji) .To efficiently store data,extensions may also be used.

As a matter of fact the QR code system became popular outside the automotive industry. Due to its fast readability and greater storage capacity compared to standard UPC barcodes. Furthermore applications include product tracking, item identification, time tracking, document management, and general marketing.

However a QR code consists of black squares arranged in a square grid on a white background.

Which can be read by an imaging device such as a camera. And processed using Reed–Solomon error correction until the image can be appropriately interpreted. The required datum is then extracted from patterns that are present in both horizontal and vertical components of the image. Finally the source of this  information Wikipedia.



Explanation

However this tutorial is for reading and generating Qr code using zxing with simple step by step processes. ZXing (“zebra crossing”) is an open-source, multi-format 1D/2D barcode image processing library implemented in Java with ports to other languages. Its focus is on using the built-in camera on mobile phones to scan and decode barcodes on the device, without communicating with a server, though the library also supports use on a server. Similarly Qr code used in payment applications like paytm also in xender for connecting. Additionally BBM. This tutorial is divided in to three parts to explain.

  1. Activity for Navigation (MainActivity).
  2. Qr Code Generator Activity.
  3. Qr Code Reader Activity.




1- Activity for Navigation (MainActivity)

MainActiviy is only for navigation purpose. Then add the required library’s (dependencies ). com.google.zxing:core is for QR Code generating and me.dm7.barcodescanner:zxing is for QR Code scanner.

In addition to dependencies permissions required are.

Navigation activity contain only two methods readQr for reader and generateQr for generator activity. Similarly click is handled by onClick inside xml.

MainActivity.java

Finally xml file for Navigation activity. However android:onClick="generateQr" and android:onClick="readQr" are for  methods generateQr(View view) and readQr(View view) accordingly.

activity_main.xml

2- Qr Code Generator Activity

First and foremost Generation of qr code using zxing take place here. However qrGenerator method contains basic properties for the qr code like height width character encoding etc. Another method createQRCode is where encoding take-place, and bitmetrix  is converted to bitmap. Then this bitmap is displayed inside the imageview.

qr code reader and generate logicchip 1

QrGenerate.java

Also Ui for Qr Generator is given below.

activity_qr_generate.xml

3- Qr Code Reader Activity

Reader class extents Activity and implements ZXingScannerView.ResultHandler. In other words me.dm7.barcodescanner.zxing is used. In detail it’s an Android library projects that provides easy to use and extensible Barcode Scanner views based on ZXing and ZBar. QrReader.java is an activity but don’t have an xml. As a result ZXingScannerView act as the ui, providing the Camera preview. We have to include the activity file for reader class in the manifest file otherwise it will result in crashing.

qr code reader and generate logicchip 2

QrReader.java

Manifest for the application.

The application require permission for camera and storage. Some times the storage permission is not required because the file is never actually saved.

AndroidManifest.xml

If you have any questions or queries drop it in the comments below.

Leave a Reply

%d bloggers like this: