Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data-capture-ready-to-use-ui-example/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version")

def scanbotSdkVersion = "8.0.0.61-STAGING-SNAPSHOT"
def scanbotSdkVersion = "8.0.0.62-STAGING-SNAPSHOT"

implementation("io.scanbot:sdk-package-4:$scanbotSdkVersion")
implementation("io.scanbot:rtu-ui-v2-bundle:$scanbotSdkVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import io.scanbot.common.onSuccess
import io.scanbot.example.databinding.*
import io.scanbot.example.fragments.*
import io.scanbot.example.util.*
Expand Down Expand Up @@ -175,15 +176,15 @@ class MainActivity : AppCompatActivity() {

init {
creditCardUiResultLauncher =
registerForActivityResult(CreditCardScannerActivity.ResultContract()) { resultEntity: CreditCardScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.creditCard?.let {
registerForActivityResult(CreditCardScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { result ->
result.creditCard?.let {
val creditCard = CreditCard(it)
val cardNumber: String = creditCard.cardNumber.value.text
val cardholderName: String = creditCard.cardholderName?.value?.text ?: ""
val expiryDate: String? = creditCard.expiryDate?.value?.text
Toast.makeText(
this,
this@MainActivity,
"Card Number: $cardNumber, Cardholder Name: $cardholderName, Expiry Date: $expiryDate",
Toast.LENGTH_LONG
).show()
Expand All @@ -193,25 +194,20 @@ class MainActivity : AppCompatActivity() {

mrzDefaultUiResultLauncher =
registerForActivityResultOk(MrzScannerActivity.ResultContract()) { resultEntity ->
if (resultEntity.resultOk) {
resultEntity.result?.mrzDocument?.let {
showMrzDialog(it)
}
resultEntity?.mrzDocument?.let {
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resultEntity is nullable but registerForActivityResultOk should return a non-null result. This inconsistency suggests either the helper function signature is incorrect or the null-safe operator is unnecessary.

Suggested change
resultEntity?.mrzDocument?.let {
resultEntity.mrzDocument.let {

Copilot uses AI. Check for mistakes.
showMrzDialog(it)
}
}

textDataScannerResultLauncher =
registerForActivityResult(TextPatternScannerActivity.ResultContract()) { resultEntity: TextPatternScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.rawText?.let {
Toast.makeText(this, it, Toast.LENGTH_LONG).show()
}
registerForActivityResultOk(TextPatternScannerActivity.ResultContract()) { resultEntity ->
resultEntity?.rawText?.let {
Toast.makeText(this, it, Toast.LENGTH_LONG).show()
}
}

vinScannerResultLauncher =
registerForActivityResultOk(VinScannerActivity.ResultContract()) { resultEntity ->
val vinScanResult = resultEntity.result!!
registerForActivityResultOk(VinScannerActivity.ResultContract()) { vinScanResult ->
Toast.makeText(
this@MainActivity,
"VIN Scanned: ${vinScanResult.textResult.rawText}",
Expand All @@ -221,12 +217,12 @@ class MainActivity : AppCompatActivity() {

dataExtractorResultLauncher =
registerForActivityResultOk(DocumentDataExtractorActivity.ResultContract()) { resultEntity ->
handleDocumentDataExtractorResult(listOfNotNull(resultEntity.result))
handleDocumentDataExtractorResult(listOfNotNull(resultEntity))
}

checkScannerResultLauncher =
registerForActivityResultOk(CheckScannerActivity.ResultContract()) { resultEntity ->
handleCheckScannerResult(resultEntity.result!!)
handleCheckScannerResult(resultEntity)
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function handleCheckScannerResult expects a non-null result, but if registerForActivityResultOk can return null, this will cause a runtime error. Consider adding a null check or verifying the return type of registerForActivityResultOk.

Suggested change
handleCheckScannerResult(resultEntity)
resultEntity?.let { handleCheckScannerResult(it) }

Copilot uses AI. Check for mistakes.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,27 @@ class StartCheckUiSnippet : AppCompatActivity() {
// @Tag("Launching the scanner")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand All @@ -88,12 +103,27 @@ class CheckPaletteSnippet : AppCompatActivity() {
// @Tag("Palette")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -139,12 +169,27 @@ class CheckLocalizationSnippet : AppCompatActivity() {
// @Tag("Localization")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -176,12 +221,27 @@ class CheckIntroductionSnippet : AppCompatActivity() {
// @Tag("Introduction")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -241,12 +301,27 @@ class CheckUserGuidanceSnippet : AppCompatActivity() {
// @Tag("User guidance")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -295,12 +370,27 @@ class CheckTopBarSnippet : AppCompatActivity() {
// @Tag("Top bar")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -340,12 +430,27 @@ class CheckFinderSnippet : AppCompatActivity() {
// @Tag("Finder overlay")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -377,12 +482,27 @@ class CheckActionBarSnippet : AppCompatActivity() {
// @Tag("Action bar")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down Expand Up @@ -434,12 +554,27 @@ class CheckScanningSnippet : AppCompatActivity() {
// @Tag("Scanning")

val resultLauncher: ActivityResultLauncher<CheckScannerScreenConfiguration> =
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity: CheckScannerActivity.Result ->
if (resultEntity.resultOk) {
resultEntity.result?.check?.let {
registerForActivityResult(CheckScannerActivity.ResultContract()) { resultEntity ->
resultEntity.onSuccess { checkResult ->
checkResult.check?.let {
// Here you can handle `check document` and present recognized Check information (routing number, account number, etc.)
wrapCheck(it)
}
}.onFailure {
// Optional activity closing cause handling to understand the reason scanner result is not provided
when (it) {
is Result.InvalidLicenseError -> {
// indicate that the Scanbot SDK license is invalid
}

is Result.OperationCanceledError -> {
// Indicates that the cancel button was tapped. or screen is closed by other reason.
}

else -> {
// Handle other errors
}
}
}
}

Expand Down
Loading