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, but it is possible to launch it as a composition (see composition).
Launching via Activity
-
Register an
ActivityResultLauncher
that will handle the result from an activity.private var faceCameraLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()) { result ->
when (result.resultCode) {
RESULT_OK -> {
val res = FaceCameraActivity.getResult()
res?.let {
//user successfully captured a face, continue workflow.
}
}
RESULT_CANCELED -> {
//call the code that you want to occur when the user cancels.
}
else -> {
val error = result.data?.getSerializableExtra(
FaceCameraActivity.ERROR_OBJECT,
SmartCaptureException::class.java
) ?: SmartCaptureException(
SmartCaptureException.ErrorCode.Unknown,
"Unknown Error"
)
//call the relevant code for a specific error case. See below for possible error codes.
}
}
}Note: Error Codes can be found here.
-
Start the activity using the
ActivityResultLauncher
you created in the previous step.val intent = Intent(this, FaceCameraActivity::class.java)
faceCameraLauncher.launch(intent)