Android library to scan QR codes and text recognition. This library is a wrapper built on top of CameraX and MLKit making it easier and faster to implement it for common use cases.
Add this to your project's build.gradle
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
And add this to your module's build.gradle
dependencies {
implementation 'com.github.maayyaannkk:Scanner:x.y.z'
}
For full example, please refer to app
module
No need to request or define camera permission, library will do that.
The simplest way to start the QR code scanner is
ScannerActivity.startActivityForQrCode(this, 1213)
or to start the text recognition
ScannerActivity.startActivityForTextRecognition(this, 1213)
Receive result
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (data != null && requestCode == 1213 && resultCode == Activity.RESULT_OK) {
val resultText = data.getStringExtra(ScannerActivity.RESULT_STRING) ?: ""
}
}