DocumentDetector v8.x

Current Version


  • Minimum Android SDK API version: minSdk 21 (Android 5 Lollipop)

  • Android SDK API version to compile: compileSdk 33

Runtime permissions

SDK size

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


If your version of Gradle is earlier than 7, add these lines to your build.gradle.

allprojects {
  repositories {
  maven { url '' }
  maven { url '' }


If your version of Gradle is 7 or newer, add these lines to your settings.gradle.

dependencyResolutionManagement {
    repositories {
        maven { url '' }
        maven { url '' }

Add support for Java 8 (skip this code if Java 8 is enabled), Data Binding and TensorFlow Model to your build.gradle file.

android {
    // Enable Data Binding, depending on the version of
    // If >= 4
    buildFeatures {
        dataBinding = true
    // If < 4
    dataBinding.enabled = true

    // Java 1.8 compatibility, allowing lambda functions
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8

    aaptOptions {
        noCompress "tflite"

As our SDKs activities use Data Binding, it is required that you enable this setting within your app. The compileOptions setting is required for SDK's built-in lambda functions, which were released in Java 8. The noCompress setting tells the compiler not to compress files with the .tflite extension used in the DocumentDetector.

Add the SDK version to the dependencies section in your build.gradle file

dependencies {
    implementation 'com.combateafraude.sdk:document-detector:{version}'

Supported documents

Currently, supported documents are:

public enum Document {
    RG_FRONT, // front of RG (where the photo is located)
    RG_BACK, // back of RG
    RG_FULL, // RG opened (showing front and back together)
    CNH_FRONT, // front of CNH (where the photo is located)
    CNH_BACK, // back of CNH 
    CNH_FULL, // CNH opened (showing front and back together)
    CRLV, // CRLV
    RNE_FRONT, // front of RNE or RNM
    RNE_BACK, // back of RNE or RNM
    PASSPORT, // passport (showing the photo and data)
    CTPS_FRONT, // front of CTPS (where the photo is located)
    CTPS_BACK, // back of CTPS
    ANY; // allows you to send any type of document, all those mentioned above, including any other document, as there are no typifications

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

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


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);


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:

new CaptureStage[]{
    new CaptureStage(CaptureMode.AUTOMATIC, 30000L, true),
    new CaptureStage(CaptureMode.AUTOMATIC, 15000L, false),
    new CaptureStage(CaptureMode.MANUAL, null, false)


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 {
    JPG ("image/jpg"),
    JPEG ("image/jpeg"),


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


MessageSettings messageSettings = new MessageSetings()

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:


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:

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);



Last updated


2023 Β© Caf. - All rights reserved