Quick Setup
After following the install instructions you are ready to launch the SDK. The quick setup will go over how to launch the SDK via an Activity to capture a document image. Alternatively, you can launch it using a Composable function (see composition).
Launching via Activity
Section titled “Launching via Activity”-
Register an
ActivityResultLauncherthat will handle the result from an activity.private val documentCameraLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->when (result.resultCode) {RESULT_OK -> {DocumentCameraActivity.latestResult?.let { documentCameraResult ->when (documentCameraResult) {is DocumentProcessingState.Failure -> {// Handle failure}is DocumentProcessingState.Success -> {// Handle success}}}DocumentCameraActivity.latestMetadata?.let { documentCameraMetadata ->// Optionally analyze metadata about the capture process}}RESULT_CANCELED -> {// Cancelled (e.g. by navigating back)}else -> {// Unexpected result code}}}:bulb: Note:
DocumentCameraActivity.latestResultis stored in memory and can only be read once. Make sure to handle the result immediately to avoid losing it. -
Start the activity using the
ActivityResultLauncheryou created in the previous step.val intent = DocumentCameraActivity.getIntent(this, DocumentScannerConfig())documentCameraLauncher.launch(intent)