> For the complete documentation index, see [llms.txt](https://docs.1kosmos.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.1kosmos.com/mobile-sdk/native/android/api-reference/classes/documentscanneractivity.md).

# DocumentScannerActivity

| Signature                                                      | Description                                                                                        |
| -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| public class DocumentScannerActivity extends AppCompatActivity | A class used to start the document scanner and return the scanned results back to the application. |

### Class constants

* **K\_DOCUMENT\_SCAN\_TYPE**: DocumentScannerType
* **K\_DVC\_ID**: Document verification ID defines the configuration to be used for scanning and verification.
* **K\_UID** : Unique ID by using it, you can filter sessions in AdminX → Verifications section.
* **K\_DOCUMENT\_SCAN\_ERROR** : String extra key used to retrieve the error message when document scanning fails. If the scanning activity returns RESULT\_CANCELED, the error details can be obtained from the result Intent using getStringExtra(K\_DOCUMENT\_SCAN\_ERROR).

### Prerequisites

The application must grant the camera permission before starting the document scan.

#### Initializing the Scanner and Retrieving Results

1. Create an **ActivityResultLauncher** to handle the result returned from the scanner activity.

   ```
        ActivityResultLauncher<Intent> documentSessionResult =
         registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
            if (result.getResultCode() == RESULT_CANCELED) {
            // Error
             return;
            }

         if (result.getResultCode() == RESULT_OK) {
          // Success
           }
        });

   ```
2. Start `DocumentScannerActivity` using an `ActivityResultLauncher` to receive the scan results.

   ```
       Intent intent = new Intent(this, DocumentScannerActivity.class);
       intent.putExtra(K_DOCUMENT_SCAN_TYPE, DocumentScannerType.DL.getValue());
       intent.putExtra(K_DVC_ID, "String DVCID"); // Optional
       intent.putExtra(K_UID, "String UID"); // Optional UID (Unique ID by using it you can filter in AdminX→Verifications).
       intent.putExtra(K_ENABLE_SCREEN_PROTECTION, true); // An optional boolean flag to enable screenshot and screen recording prevention.
       documentSessionResult.launch(intent);
   ```

#### Document Scanning Result Object

The result returned by `DocumentScannerActivity` contains the scanned document data, along with any relevant metadata or status information.

```
   {
    "data": {
        "sessionResult": "String", // SUCCESS OR FAILED
        "sessionId": "String", // Session ID
        "document": {
           // Driver License object
           // Passport object
           // IDCard object
        },
        "liveId": {
          // LiveID Object
        },
        "token": "string" // document.proof_jwt
    }
}
```

All documents—both Identity and Miscellaneous—must include the following baseline attributes:

| Type   | Parameter | Description                                                                                                                                    |
| ------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| string | id        | Represents the document's unique ID (e.g., driver's license number)                                                                            |
| string | category  | <p>Specifies the type of document being registered. The SDK currently supports two categories.<br>- identity\_document<br>- misc\_document</p> |
| string | type      | Represents the type of document that the user will try to register eg: dl, ppt, nationalid.                                                    |
| string | proofedBy | This identifies the entity responsible for proofing the document.                                                                              |

The identity documents must have the following baseline attributes:

| Type   | Parameter | Description                                      |
| ------ | --------- | ------------------------------------------------ |
| string | firstName | First name of the document holder.               |
| string | lastName  | Last name of the document holder.                |
| string | dob       | Date of birth {yyyyMMdd} of the document holder. |
| string | doe       | Date of expiry {yyyyMMdd} of document.           |
| string | face      | Base64 string of document holder's face photo.   |
| string | image     | Base64 string of document image.                 |


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.1kosmos.com/mobile-sdk/native/android/api-reference/classes/documentscanneractivity.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
