> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-sdk/android/standalone-modules/deprecated-sdks/document-detector-deprecated.md).

# DocumentDetector v7 or below (Deprecated)

## **Supported documents**

Currently, supported documents on Android are:

```java
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](https://github.com/combateafraude/public-docs/blob/docs-sdks/reduce-sdks-size.md).

## **Runtime permissions**

| Permission                  | Reason                                                                          | Required?                 |
| --------------------------- | ------------------------------------------------------------------------------- | ------------------------- |
| **`CAMERA`**                | To capture photos of the documents.                                             | Only for capture feature. |
| **`READ_EXTERNAL_STORAGE`** | To access the device external storage and select documents in the upload flow.  | Only for upload feature.  |
| **`ACCESS_FINE_LOCATION`**  | To collect connection data with the signal tower, for analytical purposes only. | No.                       |

## **Instantiating the SDK**

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

```java
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**

| Parameter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Required                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><strong><code>String mobileToken</code></strong></p><p>Token associated with your account, to use the SDK.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Yes.                                                                                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.setDocumentSteps(DocumentDetectorStep\[] documentSteps)</code></strong></p><p>Defines the document capture flow as explained <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/v7-or-below.md#documentdetectorstep">here</a></p>                                                                                                                                                                                                                                                                                                                                                         | Yes.                                                                                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.setPeopleId(String peopleId)</code></strong></p><p>User identifier for fraud profile identification purposes and to assist in the identification of Analytics logs in cases of bugs and errors.</p>                                                                                                                                                                                                                                                                                                                                                                                                                             | No. Used only for [analytics](https://github.com/combateafraude/public-docs/blob/docs-sdks/analytics.md) purposes.                                                                                                                                                                                                                                           |
| <p><strong><code>.setAnalyticsSettings(boolean useAnalytics)</code></strong></p><p>Enables/disables data gathering for <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/analytics.md">analytics</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                     | No. The default value is true.                                                                                                                                                                                                                                                                                                                               |
| <p><strong><code>.setCaptureStages(CaptureStage\[] captureStages)</code></strong></p><p>Configures the requirements for each capture stage. Typically ranging from the most demanding, requiring the highest quality, to the least demanding, with the lowest quality, as explained <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/v7-or-below.md#capturestage">here</a>.</p>                                                                                                                                                                                                                           | No.                                                                                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.setPopupSettings(boolean show)</code></strong></p><p>Enables/disables the popups displayed before each document capture.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | No. The default value is true.                                                                                                                                                                                                                                                                                                                               |
| <p><strong><code>.setLayout(@Nullable @LayoutRes Integer layoutId)</code></strong></p><p>Overrides the default SDK layout. Create a file in the layout folder of your project, copy this <a href="https://gist.github.com/murilofank/4548349dd1a3c412ce81db60ac3b0644">template</a> and make the changes you want.</p>                                                                                                                                                                                                                                                                                                                            | No.                                                                                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.setMask(MaskType type)</code></strong></p><p>Set the mask design displayed during captures. There are three types:</p><ul><li><strong><code>MaskType.DEFAULT</code></strong>, with the dotted pattern in the document format;</li><li><strong><code>MaskType.DETAILED</code></strong>, which shows an illustration of the requested document, along with the dotted mask;</li><li><strong><code>MaskType.NONE</code></strong>, which completely removes the mask.</li></ul>                                                                                                                                                     | No. The default value is **`MaskType.DEFAULT`**.                                                                                                                                                                                                                                                                                                             |
| <p><strong><code>.setMask(@DrawableRes Integer greenMask, @DrawableRes Integer whiteMask, @DrawableRes Integer redMask)</code></strong></p><p>Allows full customization of the masks displayed during document capture. Three types are required, one for each document validation feedback during capture: SUCCESS (greenMask), NORMAL (whiteMask) e ERROR (redMask). Going with this option, use masks with the same detection area as the document, this is extremely important for the algorithm to perform validations during the capture.</p>                                                                                               | <p>No. See our mask templates to get the detection area:</p><p><a href="https://gist.github.com/MiguelXCruz/b3fda2a47fc42b369f6fa6cd20821a79">NORMAL</a></p><p><a href="https://gist.github.com/MiguelXCruz/c10c07a5a4cb40e5bd5ba5152bd85596">SUCCESS</a></p><p><a href="https://gist.github.com/MiguelXCruz/e6a9723d42016d2fb0687cfae8c0cce3">ERROR</a></p> |
| <p><strong><code>.setStyle(@StyleRes int styleResourceId)</code></strong></p><p>Set up a new style guideline for the SDK. Create a styles.xml file in your project with this <a href="https://gist.github.com/murilofank/3ac0f921435466fd4e0b04d683597a38">template</a> and customize it.</p>                                                                                                                                                                                                                                                                                                                                                     | No.                                                                                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.setAudioSettings(boolean enable)</code></strong></p><p>Enables/Disables SDK audio playback.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | No. The default value is **`true`**.                                                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.setNetworkSettings(int requestTimeout)</code></strong></p><p>Defines SDK's <em>requests</em> timeout.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | No. The default value is 60 (seconds).                                                                                                                                                                                                                                                                                                                       |
| <p><strong><code>.setLuminositySensorSettings(@Nullable SensorLuminositySettings sensorLuminositySettings)</code></strong></p><p>Defines threshold between acceptable/unacceptable ambient brightness. Set <strong><code>null</code></strong> if you don't want to use this sensor.</p>                                                                                                                                                                                                                                                                                                                                                           | No. The default settings are 5 (lx).                                                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.setOrientationSensorSettings(@Nullable SensorOrientationSettings sensorOrientationSettings)</code></strong></p><p>Defines threshold between correct/incorrect device orientation. Higher the value more flexible it will be. Set <strong><code>null</code></strong> if you don't want to use this sensor.</p>                                                                                                                                                                                                                                                                                                                   | No. The default setting is 3 (m/s²).                                                                                                                                                                                                                                                                                                                         |
| <p><strong><code>.setStabilitySensorSettings(@Nullable SensorStabilitySettings sensorStabilitySettings)</code></strong></p><p>Defines stability sensor settings. Set <strong><code>null</code></strong> if you don't want to use this sensor.</p>                                                                                                                                                                                                                                                                                                                                                                                                 | No. The default setting is time 2000 (ms) and threshold 0.5 (m/s²).                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.setProxySettings(@Nullable ProxySettings proxySettings)</code></strong></p><p>Defines proxy settings. Follow <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/configurations/proxy-configuration.md">this</a> guide.</p>                                                                                                                                                                                                                                                                                                                                                                                   | No. The default setting is **`null`**.                                                                                                                                                                                                                                                                                                                       |
| <p><strong><code>.setPreviewSettings(@NonNull PreviewSettings previewSettings)</code></strong></p><p>Enables/disables and allows the configuration of the visualization of the capture performed, requesting the user's confirmation to proceed.</p>                                                                                                                                                                                                                                                                                                                                                                                              | No. The default is disabled.                                                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setAutoDetection(boolean enable)</code></strong></p><p>Enables/disables auto-detection and sensor checks. Use false to disable all checks on the device. This way, all validations will be performed on the backend after the capture.</p>                                                                                                                                                                                                                                                                                                                                                                                      | No. The default is **`true`**.                                                                                                                                                                                                                                                                                                                               |
| <p><strong><code>.setCurrentStepDoneDelay(boolean showDelay, int delay)</code></strong></p><p>Delays the activity after the completion of each step. This method can be used to display a success message on the screen itself after the capture, for example.</p>                                                                                                                                                                                                                                                                                                                                                                                | No. The default is **`false`**.                                                                                                                                                                                                                                                                                                                              |
| <p><strong><code>.setMessageSettings(MessageSettings messageSettings)</code></strong></p><p>Allows you to customize the messages displayed in the "status" balloon during the capture and analysis process. See the available attributes <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/v7-or-below.md#messagesettings">here</a>.</p>                                                                                                                                                                                                                                                                   | No.                                                                                                                                                                                                                                                                                                                                                          |
| <p><strong><code>.enableSwitchCameraButton(boolean enable)</code></strong></p><p>Enables/disables the button for the user to switch between the front and rear cameras.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | No. The default is **`true`**.                                                                                                                                                                                                                                                                                                                               |
| <p><strong><code>.setResolutionSettings(Resolution resolution)</code></strong></p><p>Allows you to set the capture resolution. The method takes as a parameter a <strong><code>Resolution</code></strong> that has the following options:</p><ul><li><strong><code>HD: 720x1280</code></strong></li><li><strong><code>FULL\_HD: 1080x1920</code></strong></li><li><strong><code>QUAD\_HD: 1440x2560</code></strong></li><li><strong><code>ULTRA\_HD: 2160x3840</code></strong></li></ul>                                                                                                                                                          | No. The default is **`Resolution.ULTRA_HD`**.                                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.setCompressSettings(@IntRange(from = 50, to = 100) int compressQuality)</code></strong></p><p>Allows you to configure the quality in the compression process. By default, all captures go through compression. The method expects values between 50 and 100 as a parameter, where 100 is the best quality compression (recommended).</p>                                                                                                                                                                                                                                                                                        | No. The default is **`100`**.                                                                                                                                                                                                                                                                                                                                |
| <p><strong><code>.enableGoogleServices(boolean enable)</code></strong></p><p>Allows you to enable/disable features of the SDK that consume GoogleServices in the SDK, we do not recommend disabling the services because of the loss of security.</p>                                                                                                                                                                                                                                                                                                                                                                                             | No. The default is **`true`**.                                                                                                                                                                                                                                                                                                                               |
| <p><strong><code>.setUseEmulator(boolean use)</code></strong></p><p>Allows the use of emulators when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                                                                                                                                                       | No. The default is **`false`**.                                                                                                                                                                                                                                                                                                                              |
| <p><strong><code>.setUseRoot(boolean use)</code></strong></p><p>Allows the use of root devices when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                                                                                                                                                        | No. The default is **`false`**.                                                                                                                                                                                                                                                                                                                              |
| <p><strong><code>.setUseDeveloperMode(boolean use)</code></strong></p><p>Enables the use of developer mode when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                                                                                                                                            | No. The default is **`false`**.                                                                                                                                                                                                                                                                                                                              |
| <p><strong><code>.setUseAdb(boolean use)</code></strong></p><p>Enables Android Debug Bridge (ADB) debugging mode when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                                                                                                                                      | No. The default is **`false`**.                                                                                                                                                                                                                                                                                                                              |
| <p><strong><code>.setUseDebug(boolean use)</code></strong></p><p>Allows you to use the app in debug mode when <strong><code>true</code></strong>. It is not recommended to enable this option, use it only for testing purposes.</p>                                                                                                                                                                                                                                                                                                                                                                                                              | No. The default is **`false`**.                                                                                                                                                                                                                                                                                                                              |
| <p><strong><code>.setGetImageUrlExpireTime (String expireTime)</code></strong></p><p>Sets the time the image URL will last on the server until it is expired. Expect to receive a time interval between "30m" to "30d".</p><p>Examples:</p><ul><li><strong><code>setGetImageUrlExpireTime("30m")</code></strong>: To set up minute(s) only</li><li><strong><code>setGetImageUrlExpireTime("24h")</code></strong>: To set up hour(s) only</li><li><strong><code>setGetImageUrlExpireTime("1h 10m")</code></strong>: To set hour(s) and minute(s)</li><li><strong><code>setGetImageUrlExpireTime("10d")</code></strong>: To set up day(s)</li></ul> | No. The default is **`3h`**.                                                                                                                                                                                                                                                                                                                                 |
| <p><a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/v7-or-below.md#uploadsettings"><strong><code>.setUploadSettings(UploadSettings uploadSettings)</code></strong></a></p><p>Define the settings for uploading documents. By enabling this option, the SDK flow will prompt the user to upload the document files instead of capturing them with the device's camera. This option also includes document quality checks. See how to set it <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/v7-or-below.md#uploadsettings">here</a>.</p>                          | No. By default, this option is disabled.                                                                                                                                                                                                                                                                                                                     |
| <p><strong><code>.setAllowedPassportCountriesList(CountryCodeList\[] countryList)</code></strong></p><p>Enables the option to allow passports from only a certain issuing country, or, a list of countries. See the complete list at: <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">ISO 3166-1 alpha-3</a></p><p>Example:</p><ul><li><strong><code>.setAllowedPassportCountriesList(new CountryCodesList\[]{CountryCodesList.BRA})</code></strong></li></ul>                                                                                                                                                                         | No. Passports issued by any country are accepted by default.                                                                                                                                                                                                                                                                                                 |
| <p><strong><code>.setStage(CafStage stage)</code></strong></p><p>Allows you to choose the environment in wich the SDK will run (production, beta). The method takes as parameter an enum <strong><code>CafStage</code></strong> to select the environment:</p>                                                                                                                                                                                                                                                                                                                                                                                    | No. The default is **`CafStage.PROD`**                                                                                                                                                                                                                                                                                                                       |
| **Enum**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | **Description**                                                                                                                                                                                                                                                                                                                                              |
| **`CafStage.PROD`**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Will use the Trust Platform **production** environment to register the SDK executions.                                                                                                                                                                                                                                                                       |
| **`CafStage.BETA`**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Will use the Trust Platform **beta** environment to register the SDK executions.                                                                                                                                                                                                                                                                             |

{% hint style="warning" %}
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
{% endhint %}

### **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:

```java
DocumentDetectorStep detectorStep = new DocumentDetectorStep(Document.RG_FRONT);
```

| Parameter                                                                                                                                                                                                                                                                                                                           | Required                                                                                   |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| <p><strong><code>Document document</code></strong></p><p>Identifies which document you want to capture in the respective step. See supported document types <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/android/deprecated/v7-or-below.md#supported-documents">here</a>.</p>                              | Yes.                                                                                       |
| <p><strong><code>.setStepLabel(@StringRes int stepLabel)</code></strong></p><p>Defines text to be shown in the lower part of the layout.</p>                                                                                                                                                                                        | No. There is a pattern by **`Document`** type.                                             |
| <p><strong><code>.setIllustration(@StringRes int illustration)</code></strong></p><p>Defines illustration to be shown in the popup prior to capture.</p>                                                                                                                                                                            | No. There is a pattern by **`Document`** type.                                             |
| <p><strong><code>.setStepAudio(@RawRes int stepAudio)</code></strong></p><p>Sets audio that will be played at the beginning of the step.</p>                                                                                                                                                                                        | No. There is a pattern by **`Document`** type.                                             |
| <p><strong><code>.setMask(@DrawableRes Integer whiteMaskResId, @DrawableRes Integer greenMaskResId, @DrawableRes Integer redMaskResId)</code></strong></p><p>Sets the masks for each document type. Using this method overrides the masks defined in the <code>.setMask</code> method of <code>DocumentDetector.Builder.</code></p> | No. The default is set by the **`.setMask`** method of the **`DocumentDetector.Builder`**. |

### **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:

| Parameter                                                                                                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><strong><code>Long durationMillis</code></strong></p><p>Duration of the stage, in milliseconds. If you do not want a timeout, parameterize <strong><code>null</code></strong>.</p>                                                                                                            |
| <p><strong><code>boolean wantSensorCheck</code></strong></p><p>Enables/Disables the use of sensors for capturing the photo.</p>                                                                                                                                                                  |
| <p><strong><code>QualitySettings qualitySettings</code></strong></p><p>Document quality check settings. If you do not want to check the quality of the document, set <strong><code>null</code></strong>.</p>                                                                                     |
| <p><strong><code>DetectionSettings detectionSettings</code></strong></p><p>Settings for automatic document detection. If you do not want to use automatic detection, set <strong><code>null</code></strong>.</p>                                                                                 |
| <p><strong><code>CaptureMode captureMode</code></strong></p><p>Document capture mode, which can be <strong><code>CaptureMode.AUTOMATIC</code></strong> or <strong><code>CaptureMode.MANUAL</code></strong>. In manual capture, a button will be enabled for the user to perform the capture.</p> |

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

```java
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**

| Parameter                                                                                                                           | Observarions                                                    |
| ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| <p><strong><code>double threshold</code></strong></p><p>Threshold that defines whether the document capture has quality or not.</p> | Ranges from 1.0 to 5.0, where 1.8 is the recommended threshold. |

#### **DetectionSettings**

| Parameter                                                                                                                                                             | Observarions                                                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong><code>double threshold</code></strong></p><p>Threshold that defines whether or not the document displayed by the user is the document being requested.</p> | A value between 0.0 and 1.0, where 0.95 is recommended.                            |
| <p><strong><code>int consecutiveFrames</code></strong></p><p>Number of consecutive correct frames for document acceptance.</p>                                        | 5 is recommended. The more frames, the longer it will take to detect the document. |

### **UploadSettings**

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

| Parameter                                                                                                                                          | Required                                                    |
| -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| <p><strong><code>.setEnable(Boolean enable)</code></strong></p><p>Enables/disables this feature.</p>                                               | No. The default is true.                                    |
| <p><strong><code>.setCompress(Boolean enable)</code></strong></p><p>Enables/disables file compression before uploading.</p>                        | No. The default is **`true`**.                              |
| <p><strong><code>.setFileFormats(FileFormat\[] fileFormats)</code></strong></p><p>Defines the file format(s) that will be accepted for upload.</p> | No. By default .PDF, .JPG, .JPEG, .PNG, .HEIF are accepted. |
| <p><strong><code>.setMaxFileSize(Integer maxFileSize)</code></strong></p><p>Sets the maximum KB limit of the file to upload.</p>                   | No. The default limit is 10000 KB (10MB).                   |
| <p><strong><code>.setActivityLayout ( Integer activityLayout)</code></strong></p><p>Defines the background layout of the document upload.</p>      | No.                                                         |
| <p><strong><code>.setPopUpLayout (Integer popUpLayout)</code></strong></p><p>Defines the layout of the document upload request popup.</p>          | No.                                                         |

Currently, the supported file formats are:

```java
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.

| Method                                                                                                                                                                                                                                                                                                                                                                                                                               | Default value                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>.setPopupDocumentSubtitleMessage(@NonNull @StringRes Integer message)</code></strong></p><p>Message displayed in the subtitle of the pop-up that brings the illustration of the document that is being requested for capture.</p>                                                                                                                                                                                   | “Posicione o documento em uma mesa, centralize-o na marcação e aguarde a captura automática.”                                |
| <p><strong><code>.setFitTheDocumentMessage(Integer message)</code></strong></p><p>Message telling you to fit the document to the mask.</p>                                                                                                                                                                                                                                                                                           | "Encaixe o documento na marcação"                                                                                            |
| <p><strong><code>.setHoldItMessage(Integer message)</code></strong></p><p>Message displayed at the moment the capture is being performed.</p>                                                                                                                                                                                                                                                                                        | "Segure assim"                                                                                                               |
| <p><strong><code>.setVerifyingQualityMessage(Integer message)</code></strong></p><p>Message displayed when the SDK makes a request to the backend, checking for quality.</p>                                                                                                                                                                                                                                                         | "Verificando qualidade…"                                                                                                     |
| <p><strong><code>.setLowQualityDocumentMessage(Integer message)</code></strong></p><p>Message displayed when the capture quality fails.</p>                                                                                                                                                                                                                                                                                          | "Ops, não foi possível ler as informações. Por favor, tente novamente"                                                       |
| <p><strong><code>.setUploadingImageMessage(Integer message)</code></strong></p><p>Message displayed when there is no quality check and the capture is being saved on the servers.</p>                                                                                                                                                                                                                                                | "Enviando imagem…"                                                                                                           |
| <p><strong><code>.setShowOpenDocumentErrorMessage(boolean show, @Nullable Integer message)</code></strong></p><p>Message displayed when displaying an open document, the message will be displayed together with the error message on the document being used, example: if the user displays an open CNH(Brazilian drive’s license), the standard error message "Essa é uma CNH Aberta" + the defined message will be displayed.</p> | "Use o documento fechado e tente novamente"                                                                                  |
| <p><strong><code>.setWaitMessage(boolean show, @Nullable Integer message)</code></strong></p><p>Message displayed when you start the camera.</p>                                                                                                                                                                                                                                                                                     | "Aguarde..."                                                                                                                 |
| <p><strong><code>.setSensorLuminosityMessage(@NonNull @StringRes Integer message)</code></strong></p><p>Message displayed when the brightness threshold is lower than expected.</p>                                                                                                                                                                                                                                                  | "Ambiente muito escuro"                                                                                                      |
| <p><strong><code>.setSensorOrientationMessage(@NonNull @StringRes Integer message)</code></strong></p><p>Message displayed when the orientation threshold is lower than expected.</p>                                                                                                                                                                                                                                                | "Celular não está na vertical"                                                                                               |
| <p><strong><code>.setSensorStabilityMessage(@NonNull @StringRes Integer message)</code></strong></p><p>Message displayed when the orientation threshold is lower than expected.</p>                                                                                                                                                                                                                                                  | "Mantenha o celular parado"                                                                                                  |
| <p><strong><code>.setWrongDocumentMessage\_RG\_FRONT(Integer message)</code></strong></p><p>Message displayed when the front of the RG(Brazilian ID card) is displayed in a different flow than expected.</p>                                                                                                                                                                                                                        | "Ops, esta é a frente do RG"                                                                                                 |
| <p><strong><code>.setWrongDocumentMessage\_RG\_BACK(Integer message)</code></strong></p><p>Message displayed when the RG(Brazilian ID card) version is displayed in a different flow than expected.</p>                                                                                                                                                                                                                              | "Ops, este é o verso do RG"                                                                                                  |
| <p><strong><code>.setWrongDocumentMessage\_RG\_FULL(Integer message)</code></strong></p><p>Message displayed when the open RG(Brazilian ID card) is displayed in a different stream than expected.</p>                                                                                                                                                                                                                               | "Ops, este é o RG aberto"                                                                                                    |
| <p><strong><code>.setWrongDocumentMessage\_CNH\_FRONT(Integer message)</code></strong></p><p>Message displayed when the front of the CNH(Brazilian driver's license) is displayed in a different stream than expected.</p>                                                                                                                                                                                                           | "Ops, esta é a frente da CNH"                                                                                                |
| <p><strong><code>.setWrongDocumentMessage\_CNH\_BACK(Integer message)</code></strong></p><p>Message displayed when the version of the CNH(Brazilian driver's license) is displayed in a different stream than expected.</p>                                                                                                                                                                                                          | "Ops, este é o verso da CNH"                                                                                                 |
| <p><strong><code>.setWrongDocumentMessage\_CNH\_FULL(Integer message)</code></strong></p><p>Message displayed when the open CNH(Brazilian driver's license) is displayed in a different stream than expected.</p>                                                                                                                                                                                                                    | "Ops, esta é a CNH aberta"                                                                                                   |
| <p><strong><code>.setWrongDocumentMessage\_CRLV(Integer message)</code></strong></p><p>Message displayed when the CRLV(Brazilian Vehicle Registration and Licensing Certificate) is displayed in a different stream than expected.</p>                                                                                                                                                                                               | "Ops, este é o CRLV"                                                                                                         |
| <p><strong><code>.setWrongDocumentMessage\_RNE\_FRONT(Integer message)</code></strong></p><p>Message displayed when the front of the RNE(National Registry of Foreigners) is displayed in a different stream than expected.</p>                                                                                                                                                                                                      | "Ops, esta é a frente do RNE"                                                                                                |
| <p><strong><code>.setWrongDocumentMessage\_RNE\_BACK(Integer message)</code></strong></p><p>Message displayed when the back of the RNE(National Registry of Foreigners) is displayed in a different stream than expected.</p>                                                                                                                                                                                                        | "Ops, este é o verso do RNE"                                                                                                 |
| <p><strong><code>.setPositiveButtonMessage(Integer message)</code></strong></p><p>Allows for customization of the confirmation button message.</p>                                                                                                                                                                                                                                                                                   | Não. O padrão é "Ok, entendi!"                                                                                               |
| <p><strong><code>.setUploadedImageIsTooLargeTitle</code></strong></p><p>Sets the title of the upload popup when the uploaded file exceeds the maximum allowed size.</p>                                                                                                                                                                                                                                                              | Não. O padrão é "Tamanho do arquivo excedido"                                                                                |
| <p><strong><code>.setUploadedImageIsTooLargeMessage</code></strong></p><p>Sets the upload popup message when the uploaded file exceeds the maximum allowed size.</p>                                                                                                                                                                                                                                                                 | Não. O padrão é "Parece que o arquivo que você escolheu excede o tamanho permitido. Tente enviar um arquivo menor."          |
| <p><strong><code>.setUploadedImageHasInvalidFormatTitle</code></strong></p><p>Sets the title of the upload popup when the format of the uploaded file is not valid.</p>                                                                                                                                                                                                                                                              | Não. O padrão é "Formato inválido."                                                                                          |
| <p><strong><code>.setUploadedImageNotSupportedFormatMessage</code></strong></p><p>Sets the upload popup message when the format of the uploaded file is not valid.</p>                                                                                                                                                                                                                                                               | Não. O padrão é "Parece que o formato do arquivo não é suportado. Tente reenviar usando os formatos de JPG, PNG ou PDF."     |
| <p><strong><code>.setUploadedImageGenericErrorTitle</code></strong></p><p>Sets the generic error title for the upload popup.</p>                                                                                                                                                                                                                                                                                                     | Não. O padrão é "Ops, algo deu errado."                                                                                      |
| <p><strong><code>.setUploadedImageWrongMessage</code></strong></p><p>Sets the generic error message for the upload popup.</p>                                                                                                                                                                                                                                                                                                        | Não. O padrão é "Parece que o documento não é o esperado. Envie um arquivo com o tipo de documento solicitado."              |
| <p><code>.</code><strong><code>setUploadedImageLowQualityTitle</code></strong></p><p>Sets the title of the upload popup when the quality of the uploaded image fails.</p>                                                                                                                                                                                                                                                            | Não. O padrão é "Ops, qualidade baixa"                                                                                       |
| <p><strong><code>.setUploadedImageLowQualityMessage</code></strong></p><p>Sets the upload popup message when the quality of the uploaded image fails.</p>                                                                                                                                                                                                                                                                            | Não. O padrão é "Parece que a qualidade da imagem documento está muito baixa. Tente enviar um arquivo com melhor qualidade." |
| <p><strong><code>.setUploadPopupLoadingMessage</code></strong></p><p>Sets the message displayed in the upload popup while the file is being uploaded.</p>                                                                                                                                                                                                                                                                            | Não. O padrão é "Enviando documento"                                                                                         |

**Example**

```java
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:

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

{% hint style="warning" %}
Disabling security validations is recommended **for testing purposes only**. For publishing your application in production, we recommend using the default settings.
{% endhint %}

## Starting Activity

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

```java
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`**:

```java
@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**

| Parameter                                                                                                                                                                                                                                           | Allow null                                                                           |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| <p><strong><code>Capture\[] captures</code></strong></p><p>The array with the respective captures of the parameterized documents.</p>                                                                                                               | Yes, in case of error                                                                |
| <p><strong><code>String type</code></strong></p><p>The class of the read document stream. This parameter is useful in an integration with our OCR route.</p>                                                                                        | Yes, in case of an error or when you couldn't check the quality.                     |
| <p><strong><code>String trackingId</code></strong></p><p>Identifier of this execution on our servers. If possible, save this field and send it along to our API. This way we will have more data on how the user behaved during the execution.</p>  | Yes, if the user sets **`useAnalytics = false`** or the analytics calls do not work. |
| <p><strong><code>SDKFailure sdkFailure</code></strong></p><p>Object that tells you the reason for the SDK shutdown. For more information, see <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/sdks-response.md">here</a>.</p> | Yes, in case of success                                                              |

#### **Capture**

| Parameter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Allow null                                 |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| <p><strong><code>String imagePath</code></strong></p><p>Full path of the image on the user's device.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                  | No.                                        |
| <p><strong><code>String imageUrl</code></strong></p><p>URL of the document on the CAF server.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                         | No.                                        |
| <p><strong><code>String label</code></strong></p><p>Identification of the type of the captured document, within the following possibilities: <strong><code>\["blank", "cnh\_back", "cnh\_front", "cnh\_full", "new\_cnh\_back", "new\_cnh\_front", "new\_cnh\_full", "crlv", "crlv\_new", "generic", "rg\_back", "rg\_front", "rg\_full", "rg\_new\_back", "rg\_new\_front", "rg\_new\_full", "rne\_back", "rne\_front", "rnm\_back", "rnm\_front", "ctps\_back", "ctps\_front", "passport", "cin\_front", "cin\_back"]</code></strong><code>.</code></p> | Yes, when you could not check the quality. |
| <p><strong><code>Double quality</code></strong></p><p>Quality is inferred by the document quality algorithm when enabled. Ranges from 1.0 to 5.0.</p>                                                                                                                                                                                                                                                                                                                                                                                                     | Yes, when you could not check the quality. |
| <p><strong><code>int lensFacing</code></strong></p><p>Defines the face of the camera that was used. Use <strong><code>DocumentDetectorResult.LENS\_FACING\_FRONT</code></strong> or <strong><code>DocumentDetectorResult.LENS\_FACING\_FRONT</code></strong> to validate.</p>                                                                                                                                                                                                                                                                             | No.                                        |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-sdk/android/standalone-modules/deprecated-sdks/document-detector-deprecated.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
