Getting started with the Android Barcode Scanner SDK's RTU UI
Adding the RTU UI dependency
The RTU UI components are distributed as a separate package rtu-ui-v2-barcode. Add it as a dependency to your project:
implementation("io.scanbot:rtu-ui-v2-barcode:$scanbotBarcodeSdkVersion")
Get the latest $scanbotBarcodeSdkVersion from the changelog.
Launching the RTU UI Barcode Scanner
With just a few lines of code, you can integrate barcode scanning into your application's workflow. It is as easy as starting an Android activity.
- AndroidX Result API
- old 'startActivityForResult' approach
loading...
loading...
We offer some syntactic sugar for handling the result from RTU UI Components via the AndroidX Result API:
-
Every RTU UI component's activity contains a
Resultclass, which (along with theresultCodevalue) exposes a booleanresultOkproperty. This will be true ifresultCodeequalsActivity.RESULT_OK. -
When you only expect
Activity.RESULT_OKresult code, you can use theAppCompatActivity.registerForActivityResultOkextension method instead ofregisterForActivityResult. It will be triggered only when there is a non-nullable result entity present.
Always use the corresponding activity's static newIntent method to create an intent when starting the RTU UI activity using the deprecated startActivityForResult approach. Creating an android.content.Intent object using its constructor (passing the activity's class as a parameter) will lead to the RTU UI Component malfunctioning.
Handling scan results
Result is represented by the sealed interface io.scanbot.common.Result, which has two main implementations: Result.Success and Result.Failure (the latter includes several more specific subclasses).
BarcodeScannerUiResult is returned only when the execution result is Result.Success. You can access it using convenience methods such as result.onSuccess { data -> /* handle data here */ }, or by retrieving the value from the result.data field.
The BarcodeScannerUiResult class provides scanned items containing rich barcode data and extracted documents.
Use its properties to retrieve text, format, and structured data.
You can find all available properties of the BarcodeScannerUiResult in the API documentation.
loading...
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial licenseScanbot SDK is part of the Apryse SDK product family
A mobile scan is just the start. With Apryse SDKs, you can expand mobile workflows into full cross‑platform document processing. Whether you need to edit PDFs, add secure digital signatures, or use a fast, customizable document viewer and editor, Apryse gives you the tools to build powerful features quickly.
Learn more
