Speed up SparkScan integration with Agent Skills
Install the Scandit plugin and use the /sparkscan-android skill so that your AI coding agent can integrate, debug, and customize SparkScan on Android following Scandit's recommended patterns. More info →
Run the following command in your project directory. It detects the supported coding agents you have installed and adds the Scandit plugin to each. Re-run it to update.
npx plugins add scandit/skillsPrefer to set it up yourself? Manual installation steps for each agent →
Advanced Configurations
SparkScan is optimized by default for efficiency, accuracy, and a seamless user experience. However, there are some cases where you might want to customize the behavior of SparkScan. This guide will show you how to add additional capabilities and further customize SparkScan to best fit your needs.
Advanced Capabilities
Hardware Button Control
Allowing the end user to control the scanner with hardware buttons can be useful if your users typically wear gloves. It can also improve ergonomics in some workflows.
SparkScan offers a built-in API to let you do this via SparkScanViewSettings.hardwareTriggerEnabled.
Trigger Error State
You may want to introduce logic in your app to show an error message when scanning specific barcodes (e.g. barcodes already added to the list, barcodes from the wrong lot etc.). SparkScan offers a built-in error state you can easily set to trigger an error feedback prompt to the user.
You can customize:
-
The text message.
-
The timeout of the error message: the scanner will be paused for the specified amount of time, but the user can quickly restart the scanning process by tapping the trigger button.
tipA high timeout (>10s) typically requires the users to interact with the UI to start scanning again. This is a good choice when you want to interrupt the scanning workflow (e.g. because a wrong barcode is scanned and some actions need to be performed). A small timeout (<2s) could allow the user to scan again without having to interact with the app, just momentarily pausing the workflow to acknowledge that a “special” barcode has been scanned.
-
The color of the flashing screen upon scan. You can enable or disable the visual feedback via SparkScanViewSettings.visualFeedbackEnabled and control the color via SparkScanBarcodeErrorFeedback.
-
The color of the highlight for the scanned barcode.
-
The feedback (sound, vibration).
To emit an error, you have to implement a SparkScanFeedbackDelegate and set it to the SparkScanView:
sparkScanView.feedbackDelegate = this
In the SparkScanFeedbackDelegate.getFeedbackForBarcode() you can then return an error or a success feedback:
override fun getFeedbackForBarcode(barcode: Barcode): SparkScanBarcodeFeedback? =
if (isValidBarcode(barcode)) {
SparkScanBarcodeFeedback.Success()
} else {
SparkScanBarcodeFeedback.Error("This code should not have been scanned",
TimeInterval.seconds(60f))
}
You can have different error states triggered by different logic conditions. For example you can trigger an error state when a wrong barcode is scanned, and another one when a duplicate barcode is scanned. These errors can show different colors and have different timeouts.

This error state for a code that should not have been scanned.

This error state for a code that has been scanned more than once.