How to create or generate QR (Quick Response) Code in your Android App? - complete source code

  Рет қаралды 12,926

Programmer World

Programmer World

Күн бұрын

In this video it shows the steps to develop your QR Code generator App in Android Studio. It uses zxing library which is included in the App by adding the dependencies in the build.gradle file (App level) for the 'com.google.zxing:core:3.2.1' implementation.
In this tutorial a very simple layout has been designed with one Text Box/ plain text field to enter the string which needs to be converted in the QR Code.
It uses the ImageViewer to display the QR code which is generated in your App in Bitmap format.
Complete source code of the App and screenshots of the test results of the QR Scanner is available at the below link:
programmerworl...
-

Пікірлер: 46
@JAntonioC
@JAntonioC 3 жыл бұрын
Great tutorial thanks
@Warren2490
@Warren2490 3 жыл бұрын
Your channel is amazing ty - another person asked this question. Can you save this QR code to another screen on the app once generated? So that another page will present a list and picture of the QR generated?
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
I think you can simply write the generated Bitmap (of the QR code) in an image file. You can use below line of code to write or create a separate image file from your App's code: fileOutputStream = new FileOutputStream(fileScreenshot); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); Above lines are copied from the source code shared at the below link: programmerworld.co/android/how-to-take-screenshot-from-your-android-app-and-open-the-image-file-programmatically/ Cheers Programmer World programmerworld.co -
@Warren2490
@Warren2490 3 жыл бұрын
@@ProgrammerWorld Thank you so much. Your support has helped a lot of people grow!
@Moustapha-08
@Moustapha-08 3 жыл бұрын
Thanks for the tutorial, I have multiple edit texts which i want to incorporate into the qr code generation such as email, phone number, and date, but the program is only reading one text edit. how do i read the other edit texts?
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
Simple, just create multiple local variables in Java code for each of your edit texts. Something like below: editText = findViewById(R.id.editText); editText1 = findViewById(R.id.editText1); editText2 = findViewById(R.id.editText2); Now, in the QR code generation method, just concatenate all the strings to create a single string which can be used to generate the QR code. Something like below: BitMatrix bitMatrix = qrCodeWriter.encode( editText.getText().toString()+ editText1.getText().toString()+ editText2.getText().toString(), BarcodeFormat.QR_CODE, 200, 200); Rest of the code will remain same as shown in the below page: programmerworld.co/android/how-to-create-or-generate-qr-quick-response-code-in-your-android-app-complete-source-code/ Hope it helps. Cheers Programmer World programmerworld.co -
@jasonarisa7132
@jasonarisa7132 4 жыл бұрын
I have a custom QR code like the ones from Apple, Facebook, and Snapchat, and I want to have it as my "QR Code" instead of the one from BitMatrix. Do you know how I can do that?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
In QR creation, text or numbers are converted into QR image. This QR image contains the information of the text embedded into it which can be read by any QR reader on scanning. Now, if you want to generate your own QR code, can you please elaborate what do you mean here? Do you want a custom format for your generated QR image? Cheers Programmer World programmerworld.co -
@jasonarisa7132
@jasonarisa7132 4 жыл бұрын
Programmer World yeah I want to create a custom scannable code like Snapcode on Snapchat. Is it possible if I create my own code format that I can use to replace QR code?
@faizaaslam100
@faizaaslam100 4 жыл бұрын
Why are we using Zing instead of Google vision library?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
Hi, To solve a problem there are always multiple approaches. Google vision is one approach given it's flexibility in APIs. Zxing is another, good for people who want to customize their APIs. Both of them have their advantages. Cheers Programmer World programmerworld.co -
@ruhlovnikita4234
@ruhlovnikita4234 4 жыл бұрын
Thx for tutorial! Although I suppose, there is a better way than manual loop for a bitmap
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
Yes, I agree there are always multiple ways to solve a problem. If it is possible can you please let us know your approach in copying the bitmap? I am just curious to understand. Cheers Programmer World programmerworld.co -
@charliecliforddevilla7836
@charliecliforddevilla7836 2 жыл бұрын
Why does the warning message always appears saying: "Insufficient text color contrast ratio"
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
This tutorial is about creating the QR code. So, I assume the warning you are getting is while reading the QR code from another phone. Probably, the contract ratio of your phone screen is not right and hence, this warning is thrown. In case you can provide more details such as when is this warning thrown then it may help us to debug the issue further. For reference, the complete source code shown in this tutorial is also shared in the below link: programmerworld.co/android/how-to-create-or-generate-qr-quick-response-code-in-your-android-app-complete-source-code/ Cheers Programmer World programmerworld.co -
@charliecliforddevilla7836
@charliecliforddevilla7836 2 жыл бұрын
​@@ProgrammerWorld Even though I did what you do in the video, the warning is still thrown. I also did what the warning says, I change the android:hintTextColor to #757575 but still warning is thrown
@patrickjosephtolentino783
@patrickjosephtolentino783 4 жыл бұрын
Hi. What code should i add if im gonna use more than 1 edittext? thanks
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
If you are looking to have multiple lines of text to get converted into QR code, then you should use multiline text box in your layout. The rest of java code will remain almost as it is. However, if you want to add the inputs from different sources or multiple edittext then simply add those edittext in your layout and in the java code append or add all the inputs (using '+' sign) to get your final input to be fed for QR code generation. Hope above explanation helps. Good Luck Programmer World programmerworld.co -
@hpwong150
@hpwong150 3 жыл бұрын
Can it generate one QR code under multiple entry such as name , class , id ?
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
Yes, of course. There are multiple ways to do it. The simplest approach will be to form one single string of all these entries and then use that to generate the QR code. Other way will be to create separate QR for each entry and then merge the QR codes into one. This approach is not recommended as it is more complex and not very efficient. Good Luck Programmer World programmerworld.co -
@hpwong150
@hpwong150 3 жыл бұрын
@@ProgrammerWorld How about if I want to generate a QR code for a student with their name, class & class number. What will be your suggestions? Thanks.
@codeSimple147
@codeSimple147 3 жыл бұрын
why do we use zxing library
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
Zxing is one of the libraries which provides QR code functionalities. There are other libraries also which can do this job. Please feel free to explore and if possible please share your findings and knowledge for betterment of others. Cheers Programmer World programmerworld.co -
@vijaykumarjain429
@vijaykumarjain429 2 жыл бұрын
How can i generate a qr code that can only be readed or reedemed only once
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
A QR Code is basically an information (such as texts, numbers, dates, images, etc.) converted into machine readable code. To read it, the machine uses a camera to read the pixels on the QR Code and based on that it derives the information which is encoded. Now, if you want a message which can only be used once (like a URL or passwords or OTP) then control it from the server which services to that message. Ensure that once the message is received from a client then server will not process it again. QR Code is just an image of the message and it cannot restrict the usage itself. I hope above explains your query. For reference, the complete details and source code shown in this video is also shared in the below link: programmerworld.co/android/how-to-create-or-generate-qr-quick-response-code-in-your-android-app-complete-source-code/ Cheers Programmer World programmerworld.co -
@Harsh-jw5iz
@Harsh-jw5iz 4 жыл бұрын
Is there any way to convert a pdf into qr_code and scan the qr_code.
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
I think the approach you can take is to convert pdf into image and then scan QR code from that image. Cheers Programmer World programmerworld.co -
@simiabradz7411
@simiabradz7411 4 жыл бұрын
Hi , did u find a way to do it? i really need your help if yes ^^
@haithemsoulai562
@haithemsoulai562 4 жыл бұрын
hi what abaut if i wanna save the qr code
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
Take the screen shot, simple. Good Luck Programmer World programmerworld.co -
@mauriciolp1380
@mauriciolp1380 4 жыл бұрын
How can I cut the border or margin?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
The final output is displayed in an ImageView widget using the below line of code: imageView.setImageBitmap(bitmap); So, to put the border or margin around the ImageView, you can view my below video for reference: kzbin.info/www/bejne/o6OtqYtqgJyCfc0 I hope above is helpful. Good Luck Programmer World programmerworld.co -
@ashrafmakandar3370
@ashrafmakandar3370 4 жыл бұрын
hi sir please make a video on mvvm
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
Can you please elaborate on what you mean by mvvm? Do you mean Model-view-viewmodel software architectural pattern? Cheers Programmer World programmerworld.co -
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
@Anish Shakya Hi Anish, Sure, I will try to make videos on mvvm topic depending on my schedule. Cheers programmerworld.co -
@everything4352
@everything4352 4 жыл бұрын
How to upload it to play store?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
To launch it on play store, you will have to first create a bundle release with your key and then upload it using the google play console. We will try to make a tutorial on this. Cheers Programmer World programmerworld.co -
@averygemgutierrez7360
@averygemgutierrez7360 3 жыл бұрын
sir how to store multiple data in a single qr code?
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
Simple. Just add all the data into a single string and then generate the QR code from that string. For making a single string, one can append or concatenate all the data into a single string variable. Hope the above helps. Cheers Programmer World programmerworld.co -
@averygemgutierrez7360
@averygemgutierrez7360 3 жыл бұрын
@@ProgrammerWorld sir can u give me some reference or example? im a beginner to this
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
@@averygemgutierrez7360 Check the source code shared in below links. It may help: programmerworld.co/android/how-to-create-or-generate-qr-quick-response-code-in-your-android-app-complete-source-code/ programmerworld.co/android/how-to-create-your-own-qr-code-and-barcode-scanner-reader-android-app-complete-source-code/ Cheers Programmer World programmerworld.co
@suryavamsi8889
@suryavamsi8889 4 жыл бұрын
hi sir how can i get value in qr code
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
What value do you want in qr code? By any chance do you mean that you want to read the generated qr code? Cheers Programmer World programmerworld.co -
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
You can refer to below video for your requirement: kzbin.info/www/bejne/rpS6n4mBo791nc0 Good Luck Programmer World programmerworld.co -
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 55 МЛН
АЗАРТНИК 4 |СЕЗОН 3 Серия
30:50
Inter Production
Рет қаралды 935 М.
大家都拉出了什么#小丑 #shorts
00:35
好人小丑
Рет қаралды 95 МЛН
No, Einstein Didn’t Solve the Biggest Problem in Physics
8:04
Sabine Hossenfelder
Рет қаралды 269 М.
QR & Barcode Scanner App Tutorial in Android Studio
13:07
Indently
Рет қаралды 132 М.
QR Code Generator - Android Studio Tutorial 1.0
27:28
Coding Beast
Рет қаралды 7 М.
QR and Barcode Scanner  |  Android Tutorial
18:54
Tech Academy
Рет қаралды 167 М.
Tesla's Self-Driving Is Going Global
19:43
Farzad
Рет қаралды 39 М.
Android Dashboard Screen Layout Design | UI Design | Android Studio
26:07
Chirag Kachhadiya
Рет қаралды 101 М.
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 55 МЛН