Generate QR Code Using Zxing Android Studio Programmatically

Hello, geeks. Welcome to Generate QR Code Using Zxing Android Studio example tutorial.

You will learn how to generate QR code in Generate QR Code Using Zxing Android Studio example.

You can generate QR Code from any string using ZXing library.

We will also save generated QRCode to internal storage.

First check output then we will develop Generate QR Code Using Zxing Android Studio example.

How to get maximum benefit from Generate QR Code Using Zxing Android example

Download Source Code

Try Our App

Download DemoNuts app to learn anytime, anywhere: Click to get Demonuts App

Or search “demonuts” in play store from android mobile device.

Creating generate create QR Code ZXing Android step by step

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Step 1: Create a new project in Android Studio.

Step 2: Updating build.gradle(Module:app) file

add following code into dependencies{} 

Step 3: Adding colors in colors.xml

Move to res->values->colors.xml directory and add following

Step 4: Updating AndroidManifest.xml file

 add required permissions between <manifest>….</manifest> tag.

Note: If you are targeting SDK version above 22 (Above Lollipop)  then you need to ask a user for granting runtime permissions. Check marshmallow runtime permission for more information.

Final code for AndroidManifest.xml file

Step 5: Updating activity_main.xml file

 Copy and paste below source code in activity_main.xml file

Step 6: Preparing class

Add following source code in class

Step 7: Description of

Following method saves the QRcode image.

IMAGE_DIRECTORY is the folder in which image is saved.

Below method will generate QRCode from given string.

Implementation of a button click.

If there is no string is entered, a message is printed to enter a string.

Otherwise, QRcode is generated and saved.

How to get exact Android example while searching in Google

Click to get Important Google searching tips

So all for generate create QR code ZXing Android Studio programmatically example tutorial. Thank you. ?

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

10 Responses

  1. Steve says:

    Your King bro, thanks 🙂

  2. Babuli says:

    Please let me know how to send a payment request to the customer for UPI payment using android

  3. Firas says:

    please consider to change the code below as it is consuming a lot of resources :

    Instead of this in the loop:
    for loop

    do this:
    int bgColor = getResources().getColor(;
    int color = getResources().getColor(R.color.white);

    for loop

  4. Panneer says:

    sir not save in folder
    pls help me

  5. Yan Myo Kyaw says:

    It is very help to me. Thanks bro.
    Be happy!

  6. Sing Song says:

    Hey,, i generate a QR using this one. my problem is…. how to make the generated QR pop out in my screen?

Leave a Reply

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