It is as easy as implementing a listener and calling another activity.
- Implement or create an instance of DocumentScannerEventReceiver implementation.
Java
// Java @Override public void onProcessingCompleted(Context context, Document document) { // Background document processing has successfully finished document.getDocumentImage(); } @Override public void onProcessingFailed(Context context, ScannerError error) { // Journey failed check Scanner Error possibilities, in JavaDocs. } @Override public void onProcessingCancelled(Context context, ScannerError error) { // Journey was cancelled by user input (onBackPresed) }
Kotlin
// Kotlin
private val response = object : DocumentScannerEventReceiver() {
override fun onProcessingCompleted(context: Context, result: Document) {
// If Scan was successful document object will be returned here.
// Document object contains document image and minimal clarification of the document if document was recognised.
}
override fun onProcessingCancelled(context: Context, scannerError: ScannerError) { // Returned when customer canceled journey, most probably onBack click. } override fun onProcessingFailed(context: Context, errorCode: ScannerError) { // Failure from which we could not recover. } }
- Register your implementation using DocumentScannerService
//Register before call
DocumentScannerService.registerEventReceiver(context, implementation);
//Unregister after call
DocumentScannerService.unregisterEventReceiver(context, implementation);
- Create an intent with destination activity is DocumentScannerActivity and start it.
// Create intent to start scanner activity
Intent myIntent = new Intent(MyActivity.this, DocumentScannerActivity.class);
startActivity(myIntent);