DocumentDetector v7.x or below

Supported documents

Currently, supported documents on Android are:

public enum Document {
    RG_FRONT, // frente do RG, parte onde está a foto
    RG_BACK, // verso do RG, onde está os dados
    RG_FULL, // RG aberta, aparecendo tanto a frente quanto o verso
    CNH_FRONT, // frente da CNH, parte onde está a foto
    CNH_BACK, // verso da CNH, parte onde está a assinatura
    CNH_FULL, // CNH aberta, aparecendo tanto a frente quanto o verso
    CRLV, // CRLV
    RNE_FRONT, // frente do RNE e RNM, onde estão os dados
    RNE_BACK, // verso do RNE e RNM, onde está a foto
    PASSPORT, // Passaporte, apenas um lado, mostrando todos os dados
    CTPS_FRONT, // Frente da CTPS, onde contém a foto
    CTPS_BACK, // Verso da CTPS, onde contém os dados
    OTHERS, // outros documentos de identificação em geral, como RNE, Identidade Militar, OAB e CRLV
    ANY; // permite o envio de qualquer tipo de documento, todos os citados acima, incluindo qualquer outro documento, pois não são feitas tipificações
}

SDK size

The SDK size is approximately 3.3 MB, which may decrease due to these elements.

Runtime permissions

Instantiating the SDK

First things first, instantiate an object of type DocumentDetector. This object will contain all your business rules for the SDK:

DocumentDetector mDocumentDetector = new DocumentDetector.Builder(String mobileToken)
    // see table below
    .build();

All parameters annotated with @Nullable can receive null values, useful if you want to configure only one of the parameters of the same method.

Builder method

Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.

DocumentDetectorStep

To create a capture flow, you will need to create an array of DocumentDetectorStep, where each element will be a capture step. To construct each DocumentDetectorStep object, you can enter the following elements:

DocumentDetectorStep detectorStep = new DocumentDetectorStep(Document.RG_FRONT);

CaptureStage

To improve the client's UX, we recommend creating difficulty stages for the DocumentDetector. For this, we offer the CaptureStage object, where you can set the following parameters:

Since the .setCaptureStages parameter is not required, if it is not used, the DocumentDetector will use this default:

QualitySettings qualitySettings = new QualitySettings(1.8);
DetectionSettings detectionSettings = new DetectionSettings(0.95, 5);

new CaptureStage[]{
    new CaptureStage(20000L, true, qualitySettings, detectionSettings, CaptureMode.AUTOMATIC),
    new CaptureStage(15000L, false, qualitySettings, detectionSettings, CaptureMode.AUTOMATIC),
    new CaptureStage(10000L, false, qualitySettings, detectionSettings, CaptureMode.MANUAL),
    new CaptureStage(null, false, qualitySettings, null, CaptureMode.MANUAL)
}

QualitySettings

DetectionSettings

UploadSettings

To enable the document upload functionality it is necessary to instantiate an object of type UploadSettings(boolean enable) and set its parameters:

Currently, the supported file formats are:

public enum FileFormat {
    PNG("image/png"),
    JPG ("image/jpg"),
    JPEG ("image/jpeg"),
    PDF("application/pdf"),
    HEIF("image/heif");
}

MessageSettings

To use, simply instantiate a MessageSettings object and use the methods as needed for customization.

Example

MessageSettings messageSettings = new MessageSetings()
.setFitTheDocumentMessage(R.string.exempleFit)
.setHoldItMessage(R.string.exempleHoldIt);

Security validations

We are constantly taking actions to make the product more and more secure, mitigating a number of attacks observed in the capture process and, consequently, reducing as many possible identity frauds as possible. The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below:

DocumentDetector.Builder("mobileToken")
    .setUseEmulator(true)
    .setUseRoot(true)
    .setUseDeveloperMode(true)
    .setUseAdb(true)
    .setUseDebug(true)
    .build();

Disabling security validations is recommended for testing purposes only. For publishing your application in production, we recommend using the default settings.

Starting Activity

After creating the DocumentDetector, start the DocumentDetectorActivity by passing this object as a parameter via extra intent:

Intent mIntent = new Intent(context, DocumentDetectorActivity.class);
mIntent.putExtra(DocumentDetector.PARAMETER_NAME, mDocumentDetector);
startActivityForResult(mIntent, REQUEST_CODE);

Getting the result

To get the DocumentDetectorResult object, which contains the captures taken by the SDK, override the onActivityResult method in the same Activity that you started the DocumentDetectorActivity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE){
        if (resultCode == RESULT_OK && data != null){
            DocumentDetectorResult mDocumentDetectorResult = (DocumentDetectorResult) data.getSerializableExtra(DocumentDetectorResult.PARAMETER_NAME);
            // check mDocumentDetectorResult.getSDKFailure() to find out why the SDK was terminated
        } else {
            // the user closed the activity
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

DocumentDetectorResult

Capture

Last updated

Logo

2023 © Caf. - All rights reserved