# Scanning Barcodes

This guide explains how to trigger the professional hardware scanner (laser/imager) on compatible terminals to read barcodes.

<Callout type="note">

This functionality is specific to devices with built-in professional scanning hardware. It does not utilize the device's standard camera.

</Callout>

## Initiating a Scan

To start the scanning process, call the `barcodeRead` method. This activates the hardware scanner and waits for a barcode to be detected.

```
manager.barcodeRead(new BarcodeCallback() {
    @Override
    public void onSuccess(BarcodeResponse barcodeResponse) {
        // Handle successful scan
        String codeData = barcodeResponse.getData(); // Hypothetical getter based on typical response objects
        Log.d("Scanner", "Barcode detected: " + codeData);
    }

    @Override
    public void onError(int errorCode) {
        // Handle scanning errors
        handleScanError(errorCode);
    }
});
```

## Handling Errors

The `onError` callback provides an integer code indicating why the scan failed.

| Error Code | Meaning | Description |
| :---- | :---- | :---- |
| **1** | Timeout | The scanner timed out before a barcode was read. |
| **2** | Not Supported | The device does not support professional barcode reading. |
| **3** | Cancelled | The user cancelled the scan (e.g., via a physical scan button). |
| **99** | Indeterminate | An unknown error occurred. |

### Example Error Handler

```
private void handleScanError(int errorCode) {
    switch (errorCode) {
        case 1:
            showToast("Scan timed out. Please try again.");
            break;
        case 2:
            showToast("Scanner hardware not available on this device.");
            break;
        case 3:
            showToast("Scan cancelled by user.");
            break;
        default:
            showToast("Unknown scanner error: " + errorCode);
            break;
    }
}
```