![]() |
VOOZH | about |
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.
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. |
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.
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.
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.
Below is the code for the strings.xml 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
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.
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.
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