Displaying on Android
Overview
In this use case, in addition to capturing and uploading the images, an Edit Metadata screen is shown to the user while the documents are uploaded and processed.
Launch the Activity
To display Edit Metadata screen upon completion of the Capture, launch CaptureWithMetadataFlowActivity
Example
val intent = Intent(this, CaptureWithMetadataFlowActivity::class.java)
// If you wish to, override the default capture config
val captureConfig = CaptureConfig.defaultConfig.copy(enableLongCapture = false)
intent.putExtra(CaptureWithMetadataFlowActivity.ARG_CAPTURE_CONFIG, captureConfig)
// If the receipt should be attached to some external transaction. Please note that an external account transaction
// id can only be provided if `CaptureConfig.maxImages` is set to 1
val externalAccountTransactionId = "someId"
intent.putExtra(CaptureWithMetadataFlowActivity.ARG_EXTERNAL_ACCOUNT_TRANSACTION_ID, externalAccountTransactionId)
// If the result of the capture action doesn't need to be checked, or you're observing transaction
// updates separately via your own `TransactionDataObserver`
startActivity(intent)
// If you wish to know upon the activity finishing if images were successfully captured
startActivityForResult(intent, MY_REQUEST_CODE)
final Intent intent = new Intent(this, CaptureWithMetadataFlowActivity.class);
// If you wish to override the default capture config
final CaptureConfig captureConfig = new CaptureConfig(
true,
FlashMode.FLASH_MODE_OFF,
true,
true,
false,
true,
true,
false,
1,
false,
true,
true,
true,
true,
true
);
intent.putExtra(CaptureWithMetadataFlowActivity.ARG_CAPTURE_CONFIG, captureConfig);
// If the receipt should be attached to some external transaction. Please note that an external account transaction
// id can only be provided if `CaptureConfig.maxImages` is set to 1
final String externalAccountTransactionId = "someId";
intent.putExtra(CaptureWithMetadataFlowActivity.ARG_EXTERNAL_ACCOUNT_TRANSACTION_ID, externalAccountTransactionId);
// If the result of the capture action doesn't need to be checked, or you're observing transaction
// updates separately via your own `TransactionDataObserver`
startActivity(intent);
// If you wish to know upon the activity finishing if images were successfully captured
startActivityForResult(intent, MY_REQUEST_CODE);
Additonal References:
Optional: Handling the Result
If desired, handle the result of the activity. Or you can monitor the receipts as they are processed, as explained on Document Monitoring page.
// Only required if using `startActivityForResult`
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
MY_REQUEST_CODE -> {
if (resultCode == Activity.RESULT_OK) {
// Handle receipts being successfully captured.
// At this point, the receipts could be uploading, uploaded and processing, processed,
// or failed to process.
// In order to get more granular information, you should implement your own `TransactionDataObserver`
} else {
// Handle receipt capture failure. This most likely means that the user cancelled the capture flow.
}
}
else -> super.onActivityResult(requestCode, resultCode, data)
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == MY_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
// Handle receipts being successfully captured.
// At this point, the receipts could be uploading, uploaded and processing, processed,
// or failed to process.
// In order to get more granular information, you should implement your own `TransactionDataObserver`
} else {
// Handle receipt capture failure. This most likely means that the user cancelled the capture flow.
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}