Page Properties | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Info |
---|
We recommend using Capture Flow with Fragments instead of activities. |
In order to use the capture flow with activities, follow these steps:
Request camera access.
Configure the capture feature using the
CaptureConfiguration
.Register an activity result handler with the
CaptureFlowContract()
.Launch the SDK with
GiniBank.startCaptureFlow()
.Handle the extraction results (e.g. in the
registerForActivityResult
).Send the final transfer summary values to Gini by calling
GiniBank.sendTransferSummary()
method which will be used to improve the future extraction accuracyClean up the SDK by calling
GiniBank.releaseCapture()
which will release the resources used by SDK.
...
Note |
---|
|
...
Drawio | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
CaptureResult.Success
A document was analyzed analysed and the extractions are available in the properties of the CaptureResult.Success
object.
...
Code Block | ||
---|---|---|
| ||
// Use the androidx's Activity Result API to register a handler for the capture result. val captureLauncher = registerForActivityResult(CaptureFlowContract()) { result: CaptureResult -> when (result) { is CaptureResult.Success -> { handleExtractionsshowExtractions(result.specificExtractions) } is CaptureResult.Error -> { when (result.value) { is ResultError.Capture -> { val captureError: GiniCaptureError = (result.value as ResultError.Capture).giniCaptureError handleCaptureError(captureError) } is ResultError.FileImport -> { // See the File Import section on the Capture Features page for more details. val fileImportError = result.value as ResultError.FileImport handleFileImportError(fileImportError) } } GiniBank.sendTransferSummaryreleaseCapture(this) } "", "", "", "", "", Amount.EMPTY CaptureResult.Empty -> { handleNoExtractions() GiniBank.releaseCapture( this ) } CaptureResult.EmptyCancel -> { handleNoExtractionshandleCancellation() GiniBank.sendTransferSummaryreleaseCapture(this) } "", "", "", "", "", Amount.EMPTY CaptureResult.EnterManually -> { handleEnterManually() GiniBank.releaseCapture( this ) } } } CaptureResult.Cancel -> fun startGiniBankSDK() { // Make sure camera permission has been already handleCancellation()granted at this point. // Instantiate the networking GiniBankimplementation.sendTransferSummary( val networkService: GiniCaptureNetworkService = ... // "", "", "", "", "", Amount.EMPTY Configure the capture feature. ) GiniBank.releaseCapturesetCaptureConfiguration( CaptureConfiguration( this networkService = networkService, ) ... } ) CaptureResult.EnterManually -> { ) // Launch and wait for handleEnterManually() the result. GiniBank.sendTransferSummarystartCaptureFlow(captureLauncher) } fun stopGiniBankSDKWithTransferSummary(paymentRecipient: String, "", "", "", "", "", Amount.EMPTY ) paymentReference: String, GiniBank.releaseCapture( this ) }paymentPurpose: String, } } fun launchGiniCapture() { // Make sure camera permission has been already granted at this point. // Instantiate the networking implementation. val networkServiceiban: GiniCaptureNetworkServiceString, = ... // Configure the capture feature. GiniBank.setCaptureConfiguration( CaptureConfiguration( networkService = networkService, bic: String, ... ) ) // Launch and wait for the result. GiniBank.startCaptureFlow(captureLauncher) }amount: Amount fun stopGiniBankSDK() { // After the user has seen and potentially corrected the extractions, send the final // transfer summary values to Gini which will be used to improve the future extraction accuracy: GiniBank.sendTransferSummary( paymentRecipient, paymentReference, paymentPurpose, iban, bic, amount ) // cleanup the capture SDK after sending the transfer summary GiniBank.releaseCapture(this) } |