Android Kaki

Build beautiful, usable products using required Components for Android.

Google Code Scanner makes it straightforward to scan codes on Android | by Nav Singh | April 2023


The aim of this text is to elucidate how we will combine code scanning operate into our Android apps utilizing Google’s Code Scanner API.

Scan outcomes To be give again simply to software by way of Google Play companieswhich all code scanning work.

minSdkVersion worth of ≥ 21

Add dependencies

dependencies {
implementation 'com.google.android.gms:play-services-code-scanner:16.0.0'
}

Add metadata to routinely obtain scanner modules


...
android:title="com.google.mlkit.imaginative and prescient.DEPENDENCIES"
android:worth="barcode_ui"/>
...

we will use ModuleInstallClient API ARRIVE clear verify the scanner module availability and request obtain as a result of Google Play companies

  • Configure barcode scanner choices — GmsBarcodeScannerOptions [Optional]
val choices = GmsBarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_AZTEC)
.construct()
  • Take an instance of GmsBarcodeScanner
val scanner = GmsBarcodeScanning.getClient(this)
// Or with a configured choices


val choices = GmsBarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_AZTEC)
.construct()


val scanner = GmsBarcodeScanning.getClient(this, choices)

  • Begin scanning ║▌║█║▌│║▌║▌█
non-public enjoyable initiateScanner(
gmsBarcodeScanner: GmsBarcodeScanner,
onSuccess: (Barcode) -> Unit,
onCancel: () -> Unit,
onFailure: (Exception) -> Unit
) {
gmsBarcodeScanner.startScan()
.addOnSuccessListener { barcode ->
// Activity accomplished efficiently
val end result = barcode.rawValue
Log.d(TAG, "initiateScanner: $end result")
// verify the worth - URL, TEXT, and so forth.
when (barcode.valueType) {
Barcode.TYPE_URL -> {
Log.d(TAG, "initiateScanner: ${barcode.valueType}")
}
else -> {
Log.d(TAG, "initiateScanner: ${barcode.valueType}")
}
}
// Show valu
Log.d(TAG, "initiateScanner: Show worth: ${barcode.displayValue}")
// Formate - FORMAT_AZTEC, and so forth.
Log.d(TAG, "initiateScanner: Format: ${barcode.format}")
onSuccess(barcode)
}
.addOnCanceledListener {
// Activity canceled by the consumer
onCancel()
}
.addOnFailureListener { e ->
// Activity failed with an exception
onFailure(e)
}
}
John Wick: Chapter 4 (FREE) FULLMOVIE The Super Mario Bros Movie avatar 2 Where To Watch Creed 3 Free At Home Knock at the Cabin (2023) FullMovie Where To Watch Ant-Man 3 and the Wasp: Quantumania Cocaine Bear 2023 (FullMovie) Scream 6 Full Movie
Updated: April 22, 2023 — 11:28 pm

Leave a Reply

Your email address will not be published. Required fields are marked *

androidkaki.com © 2023 Android kaki