Configuring Scanning and Preview Behavior
SparkScan can be customized to fit a wide range of scanning workflows through the combination of Scanning Mode, Scanning Behavior, and Preview Behavior.
This guide explains all valid combinations and when to use them, along with code examples to help you configure your SparkScan setup.
Scanning Modes
The following scanning modes are available:
| Mode | Description |
|---|---|
| Default | Optimized for close-range, fast-paced scanning. User can aim easily at the intended barcode. |
| Target | Best for precise scanning when many barcodes are in view. Adds an aimer to the camera preview. |
Each scanning mode can be configured to work with different scanning behaviors and preview behaviors.
Scanning Behaviors
| Behavior | Description |
|---|---|
| Single scan | Scans one barcode at a time. Requires user interaction before each scan. Ideal for controlled scanning and saving battery. |
| Continuous scan | Scans barcodes continuously after being triggered once. Ideal for scanning multiple barcodes quickly. |
Preview Behaviors
| Behavior | Description |
|---|---|
| Default | Preview fades out when scanner is off. Helps with battery conservation and allows full view of the app interface. |
| Persistent | Preview remains darkened when scanner is off. Useful for environments where visual context or barcode selection is always needed. |
Available Configurations
This combination allows for flexible configurations to suit different scanning needs.
Default Mode + Single Scan + Default Preview
Ideal for basic, one-barcode-at-a-time scanning with minimal power usage.
val settings = SparkScanSettings()
settings.scanningBehavior = ScanningBehavior.SINGLE
val sparkViewSettings = SparkScanViewSettings()
sparkViewSettings.scanningMode = SparkScanScanningMode.DEFAULT
sparkViewSettings.previewBehavior = PreviewBehavior.DEFAULT
val sparkView = SparkScanView(context, sparkViewSettings)