VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-read-qr-code-using-camview-library-in-android/

⇱ How to Read QR Code using CAMView Library in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Read QR Code using CAMView Library in Android?

Last Updated : 23 Jul, 2025

CAMView Library is a simple solution for accessing users' device camera. By using this library we can access users' cameras and use to perform so many functions of the camera such as scanning barcodes that are done by using a built-in ZXing decoding engine. This library contains a set of components that are ready to be put in your layout in order to give instant access to so many features. This library handles low-level routines such as camera, configuration, streaming, orientation, and many more. We just have to follow some basic steps to use this library. 

Important Methods

Methods

Description

onScannerStarted()This method can be used when the scanner is started.
onScannerStopped()This method is called when the scanner is stopped. 
onScannerError()This method is used when the scanner gives some error.
onCodeScanned()This method is called when the scanner scans the data from the camera. 

Implementation of CAMView Library

Using this library we will create a simple QR Code scanning app that will scan data from the QR code and display it in a TextView. A sample GIF is given below to get an idea about what we are going to do in this article.

Note that we are going to implement this project using the Java language. 


Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add dependency to build.gradle(Module:app)

Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section. 

implementation ('eu.livotov.labs.android:CAMView:2.0.1@aar') {transitive=true}

Now sync option will appear at the top right corner click on the sync now option. 

Step 3: Modify the strings.xml file

Below is the code for the strings.xml file.

Step 4: Add permission for the camera in the manifest file 

 We are adding a camera and vibrate permission in our manifest file. Navigate to the app > manifest to find AndroidManifest.xml. Below is the code snippet for AndroidManifest.xml

Step 5: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.  

Step 6: Working with the MainActivity.java file

Navigate to the app > java > your apps package name > MainActivity.java file. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail. 

Output: Run on a Real Device

Now run your app on a real device and scan some sample QR code and you will get to test the app. Make sure to allow camera permission on app launch. 

GitHub link for this project:https://github.com/ChaitanyaMunje/QR_Code_Scanner

Comment

Explore