Kotlin
Template-Based Barcode Scanning
Creating a template is straight forward. All you need to do is call the following public function and pass in your FragmentManager. It will show a user interface, with camera preview, using which you can create a template. After creating a template, you will get the String ID of newly created template in a callback function onTemplateCreated. Or if you dismiss, then onCancelled will be called.
🎯 Use Case
Imagine a shipping label that includes:
- A QR code for tracking
- A Code128 for internal processing
- A UPC for product identification
With template-based scanning, you can configure the SDK to scan only the tracking QR code and ignore the others.
🧩 Creating a Template
To create a custom template, you need to first make sure that your Activity extends from ComponentActivity. We have extension functions added in ComponentActivity that you can use to start the Activity to create a template. We also have extension callback for when a template is created.
Starting the Template Creation Activity
💾 Managing Template
The Vision SDK automatically saves created templates into its secure storage. You can manage these templates using the following methods:
Retrieve all saved template IDs:
Delete a specific template:
Update a specific template:
📸 Scanning with a Template
After creating and saving a template, you can configure the scanner to use it for scanning specific barcodes:
✅ Benefits
- Selective Scanning: Focus on specific barcodes within a document.
- Efficiency: Reduce processing time by ignoring irrelevant barcodes.
- Customization: Tailor scanning behavior to match your document layouts.