Practice and reinforce the concepts from Lesson 5
Time needed: 30-35 minutes
Get ready to build your very own QR Code Scanner app! Just like the apps on your phone that scan QR codes at restaurants or stores, you'll create a powerful scanner that can read both barcodes and QR codes. You'll even make it smart enough to know when it finds a website link!
Please watch this video to see how this app works.
The sample UI of the app and components that you will be using to make the app:
Sample UI | Components |
---|---|
![]() |
Layout: • Vertical Arrangement Visible Components: • Label • Button Non-visible Components: • Barcode Scanner • Activity Starter • Notifier |
In this app, you will need to program 2 different buttons. Program what happens when the users interact with each button.
BEFORE you code this app, please check whether or not you have set the properties in correctly. You will need to change the default settings of some components respectively in order to run this app smoothly.
Component | Property Setting | Reason |
---|---|---|
![]() |
Untick "Enabled" ![]() |
To make sure the Show Result Again button is not clickable before the users scan any barcode. |
![]() |
Untick "Use external scanner" ![]() |
To use MIT App Inventor default build-in scanner instead of installing another external scanner on your phone to activate the barcode scanner. |
![]() |
Write android.intent.action.VIEW under "Action" box ![]() |
To enable users to open a browser to a specific web page. You will need to specify what is the DataUri in ![]() |
:bulb: "Stuck?"
Remember to change these settings BEFORE you start coding! Each setting has a special purpose to make your app work correctly.
When users click on the Scan button, the BarcodeScanner will start to scan the barcode or QR Code. [Hint: Only 2 blocks.]
After you scan the barcode or QR code:
Enable the Show Result Again button.
Check what type of result you got:
Notifier with "Go to website" button for URL results
Notifier without "Go to website" button for non-URL results
:bulb: "Stuck?"
Use the "contains text" block to check if your result has "http" in it. This tells you if it's a website link!
If the user chooses "Go to website", program ActivityStarter to open the link. [Hint: 8 blocks in total.]
When users click on the Show Result Again button, they can view the previous result again.
[Hint: The exact same codes as in step 3. You may use a procedure to make your codes shorter and more efficient.]
:bulb: "Stuck?"
A procedure is like a recipe - you write the code once and can use it many times! This saves you from typing the same blocks over and over.
Now comes the fun part - testing your scanner!
Test QR codes for scanning practice
Ready to make your scanner even cooler? Try these challenges:
After completing your QR Code Scanner app, test your understanding of barcodes and QR codes by completing this knowledge assessment quiz.
Quiz Link: Barcode & QR Code Knowledge Assessment
Note: This quiz will help reinforce your understanding of the concepts covered in this lesson. Make sure to complete it after finishing your app development!