Member-only story
Create Multi-Barcode and QR Code Scanner for Continued Scanning in Android Kotlin.
Today, we will learn how to create multiple barcode and QR code scanners, mostly used in malls and retail stores to count prices and products. So, let's start.
First, we need to add a barcode scanner dependency in the build. Gradle(:app) file
//barcode
implementation 'com.google.android.gms:play-services-vision:20.1.3'
In this project, I am using view binding so we need to add a build feature in the build. Gradle(: app) file.
android {
buildFeatures {
viewBinding = true
}
}
Now we need to add camera permission in the manifest file. We will add a user feature in the manifest file for accessing the camera hardware.
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
Let’s start with the scanner design in the activity_main.xml file.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<SurfaceView…