public interface BarcodeScanService
Example
String barcodeValue = Services.get(BarcodeScanService.class)
.flatMap(service -> service
.scan("Scan View Title", "Place a barcode under the camera", "Barcode found with value"))
.orElse("No barcode found"));
System.out.println("Scanned Bar Code: " + barcodeValue)
Android Configuration
The permission android.permission.CAMERA
needs to be added together
with the following activity
configuration that handles the SCAN intent
of the BarcodeScanService.
<manifest ...>
<uses-permission android:name="android.permission.CAMERA"/>
...
<application ...>
...
<activity android:name="com.gluonhq.impl.charm.down.plugins.android.scan.zxing.CaptureActivity"
android:screenOrientation="sensorLandscape"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.gluonhq.charm.down.plugins.android.scan.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.gluonhq.impl.charm.down.plugins.android.PermissionRequestActivity" />
</application>
</manifest>
iOS Configuration
The following keys are required:
<key>NSCameraUsageDescription</key>
<string>Reason to use Camera Service (iOS 10+)</string>
Modifier and Type | Method and Description |
---|---|
java.util.Optional<java.lang.String> |
scan()
Starts up the scanner functionality (commonly provided via the camera),
and then parsed by Charm Down to determine the string the barcode represents.
|
java.util.Optional<java.lang.String> |
scan(java.lang.String title,
java.lang.String legend,
java.lang.String resultText)
Starts up the scanner functionality (commonly provided via the camera),
and then parsed by Charm Down to determine the string the barcode represents.
|
java.util.Optional<java.lang.String> scan()
java.util.Optional<java.lang.String> scan(java.lang.String title, java.lang.String legend, java.lang.String resultText)
title
- The title of the scan view. If null or empty nothing will be
displayed.legend
- An explanatory message displayed in the scan view. If null or
empty nothing will be displayed.resultText
- The text to display when the scan ends successfully, before
the scanned text. If empty or null, the result won't be shown.