How to Scan and Generate QR Code in Android

QR code is 2 Dimensional bar code that first designed for Automotive industry in Japan. The QR Code contain information about the item, it able to generate by using a readable human text and decode a QR Code to a readable human text. QR Code is to make the machine easier to understand the information of the specific item by scanning though it. It is far more popular and useful in the world right now. In this tutorial, I will tell you how to scan and generate QR Code in android by using zxing library so you can use it as a feature in your future project.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “ZxingExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Add a new dependency

After creating a new project, go to add the new dependency for embeded zxing library so you can use zxing in your project.

Edit activity_main.xml layout

Then go to the activity_main.xml and add two buttons,one edit text and one imageview in the relative layout such as the source code in the bottom.

Edit MainActivity.java class

Last, open the mainactivity class and perform the scan and generate qr code feature. You can copy and paste the sample code below.

Run your Project

Finally, the qr scanner and generator has been implement until the end, now its time to run the project in your emulator or android device.

(How to Scan and Generate QR Code in Android)

Source Code

(Visited 953 times, 1 visits today)
Advertisements

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *