Skip to content

Convenience API for ID PASS SmartScanner to simplify the Intent call out process

License

Notifications You must be signed in to change notification settings

newlogic/smartscanner-android-api

Repository files navigation

SmartScanner Android API

Convenience API for SmartScanner Core to simplify the Intent call out process.

This library provides methods that can be called to initiate scanning of MRZ, barcode, and ID PASS Lite cards, instead of manually creating and calling intents.

Note: The library's API might keep evolving before we reach v1.0, so be careful when upgrading between these pre-v1.0 versions. Starting at v1.0 we will be careful in introducing breaking API changes.

Installation

Declare Maven Central repository in the dependency configuration, then add this library in the dependencies. An example using build.gradle:

repositories {
  mavenCentral()
}

dependencies {
  implementation "org.idpass:smartscanner-android-api:0.0.1-SNAPSHOT"
}

If you want to build this library from source, instructions to do so can be found in the Building from source wiki page.

Usage

The API methods are all provided in the ScannerIntent class. Import it in order to start using the library:

import org.idpass.smartscanner.api.ScannerIntent
import org.idpass.smartscanner.api.ScannerConstants

Then call the desired method from the ScannerIntent class, for example to initiate an MRZ scan:

class MainActivity : AppCompatActivity() {

  private const val OP_SCANNER = 1001 // Activity request code

  override fun onStart() {
    super.onStart()

    try {
      val intent = ScannerIntent.intentMrz(isManualCapture = true, mrzFormat = ScannerConstants.MRZ_FORMAT_MRTD_TD1)
      startActivityForResult(intent, OP_SCANNER)
    } catch (ex: ActivityNotFoundException) {
      ex.printStackTrace()
    }
  }

  public override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
    super.onActivityResult(requestCode, resultCode, intent)

    if (requestCode == OP_SCANNER) {
      if (resultCode == Activity.RESULT_OK) {
        val bundle = intent?.getBundleExtra(ScannerConstants.RESULT)
      }
    }
  }

}

API

ScannerIntent

  • intentBarcode() : Create an Android Intent for scanning barcodes.

    • Parameters:
      • useODK : Boolean, default: false. Whether to create intents for ODK or not.
    • Return: Intent
  • intentIDPassLite() : Create an Android Intent for scanning ID PASS Lite cards.

    • Parameters:
      • useODK : Boolean, default: false. Whether to create intents for ODK or not.
    • Return: Intent
  • intentMrz() : Create and Android Intent for scanning MRZ.

    • Parameters:
      • useODK : Boolean, default: false. Whether to create intents for ODK or not.
      • isManualCapture : Boolean, default: false. Whether the MRZ is captured manually by the user or automatically once MRZ data is detected. This is added as extended data to the created Intent.
      • mrzFormat : String, default: null. The MRZ format to be scanned. One of the supported MRZ formats. This is added as extended data to the created Intent.
    • Return: Intent

ScannerConstants

Provides constant variables that can be used instead of hardcoded strings. We recommend using these constants when working with this library and smartscanner-core.

Related projects

License

Apache-2.0 License

About

Convenience API for ID PASS SmartScanner to simplify the Intent call out process

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Languages