> For the complete documentation index, see [llms.txt](https://regulaforensics.gitbook.io/android/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://regulaforensics.gitbook.io/android/5.0-2/show-scanner.md).

# Show scanner

This page covers the description of how to open the camera activity

After the [initialization](/android/5.0-2/initialization.md) is completed and the [scenario](/android/5.0-2/scenarios.md) is set, you can start document scanning process. There are several options on how to open the camera activity.

### #1

Use this method to open camera preview activity using the default back camera, which will pass frames for recognition and return results in the [completion block](/android/5.0-2/show-scanner.md#completion-callback) when they are ready:

{% tabs %}
{% tab title="Java" %}

```java
DocumentReader.Instance().showScanner(completion);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
DocumentReader.Instance().showScanner(completion)
```

{% endtab %}
{% endtabs %}

### #2

Use this method to open camera preview activity using the specified camera, which will pass frames for recognition and return results in the [completion block](/android/5.0-2/show-scanner.md#completion-callback) when they are ready:

{% tabs %}
{% tab title="Java" %}

```java
DocumentReader.Instance().showScanner(0, completion);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
DocumentReader.Instance().showScanner(0, completion)
```

{% endtab %}
{% endtabs %}

### Completion callback

The current results are returned in the completion block from each camera shot with different actions ([`DocReaderAction`](/android/5.0-2/enumerations/docreaderaction.md) enum) during the scanning process:

* **COMPLETE** - scanning process was finished
* **PROCESS** - scanning process is not finished, you can get an intermediate result from the completion block
* **CANCEL** - scanning process was canceled by the user

{% tabs %}
{% tab title="Java" %}

```java
private DocumentReader.DocumentReaderCompletion completion = new DocumentReader.DocumentReaderCompletion() {
    @Override
    public void onCompleted(int action, DocumentReaderResults results, String error) {
        // processing is finished, all results are ready
        if (action == DocReaderAction.COMPLETE) { 
            // scanning process was finished              
        } else {
            // something happened before all results were ready
            if (action == DocReaderAction.CANCEL){
                Toast.makeText(MainActivity.this, "Scanning was cancelled",Toast.LENGTH_LONG).show();
            } else if(action == DocReaderAction.ERROR){
                Toast.makeText(MainActivity.this, "Error:" + error, Toast.LENGTH_LONG).show();
            }
        }
    }
};
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
private val completion = DocumentReader.DocumentReaderCompletion { action, results, error ->
    // processing is finished, all results are ready
    if (action == DocReaderAction.COMPLETE) {
        // scanning process was finished
    } else {
        // something happened before all results were ready
        if (action == DocReaderAction.CANCEL) {
            Toast.makeText(this@MainActivity, "Scanning was cancelled", Toast.LENGTH_LONG).show()
        } else if (action == DocReaderAction.ERROR) {
            Toast.makeText(this@MainActivity, "Error:$error", Toast.LENGTH_LONG).show()
        }
    }
}
```

{% endtab %}
{% endtabs %}
