# Scanner

## Overview

Are you thinking in implements a barcode reader in your app? TotalCross have a simple solution. It is easy to make a Scanner application and there is an example ready to use on GitHub!

## Methods

| Name                     | Description                |
| ------------------------ | -------------------------- |
| readBarcode(String mode) | <p>The mode can be one of: |

</p><p>    1D - for one dimension barcodes</p><p>    2D - for QR codes</p><p>    empty string - for both<br></p><p>The parameter &#x26;msg:</p><p>You can show a message in display</p> |

## How to use

There are two ways to make the scanner.

### With Scandit:

&#x20;When we do a Scanner.readBarcode and we set on parameter characters "scandit:" with a String contains the scandit key and the camera be call and will capture the image and set on the label result. You will use like this:

&#x20;`scan = Scanner.readBarcode("scandit:" + YOUR_SCANDIT_KEY);`

### With ZXing:

In here, we have a little more work because we need find the barcode's mode, if is a 1D or 2D and just after that, we can write Scanner.readBarcode and set the mode and a message telling the user how scanner the barcode.

`scan = Scanner.readBarcode("mode=" + mode + "&msg=" + msg);`

## References

* See more in [Javadoc](https://rs.totalcross.com/doc/totalcross/io/device/scanner/package-summary.html)
* See a project using scanner on [github](https://github.com/TotalCross/ScanditSample)


---

# Agent Instructions: 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:

```
GET https://learn.totalcross.com/documentation/apis/barcode-scanner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
