You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first step to add capture capabilities to your application is to create a new [Data Capture Context](https://docs.scandit.com/data-capture-sdk/android/core/api/data-capture-context.html#class-scandit.datacapture.core.DataCaptureContext). The context expects a valid Scandit Data Capture SDK license key during construction.
2
2
3
-
```java
4
-
DataCaptureContext dataCaptureContext =DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
3
+
```kotlin
4
+
val dataCaptureContext =DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --")
This extension allows Code 39 to encode all 128 ASCII characters instead of only the 43 characters defined in the standard. The extension is disabled by default as it can lead to false reads when enabled.
Copy file name to clipboardExpand all lines: docs/sdks/android/barcode-capture/get-started.md
+36-41Lines changed: 36 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,14 +56,15 @@ Barcode scanning is orchestrated by the [BarcodeCapture data capture mode](https
56
56
57
57
For this task, we setup barcode scanning for a small list of barcode types, called [symbologies](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/symbology.html#enum-scandit.datacapture.barcode.Symbology). The list of symbologies to enable is application specific. We recommend that you only enable the symbologies your application requires. If you are not familiar with the symbologies that are relevant for your use case, you can use [capture presets](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/capture-preset.html#enum-scandit.datacapture.barcode.CapturePreset) that are tailored for different verticals (for instance, retail, logistics, and so on).
@@ -72,8 +73,8 @@ If you are not disabling barcode capture immediately after having scanned the fi
72
73
73
74
Next, create a [BarcodeCapture](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/barcode-capture.html#class-scandit.datacapture.barcode.BarcodeCapture) instance with the settings initialized in the previous step:
val recognizedBarcodes= session.newlyRecognizedBarcode
93
93
// Do something with the barcodes. See Rejecting Barcodes, below, for an example.
94
94
}
95
95
```
96
96
97
97
Then add the listener:
98
98
99
-
```java
100
-
barcodeCapture.addListener(this);
99
+
```kotlin
100
+
barcodeCapture.addListener(this)
101
101
```
102
102
103
103
### Rejecting Barcodes
@@ -106,11 +106,11 @@ To prevent scanning unwanted codes, you can reject them by adding the desired lo
106
106
107
107
The example below will only scan barcodes beginning with the digits `09` and ignore all others, using a transparent brush to distinguish a rejected barcode from a recognized one:
108
108
109
-
```java
109
+
```kotlin
110
110
...
111
-
if (barcode.getData()==null||!barcode.getData().startsWith("09:")) {
112
-
overlay.setBrush(Brush.transparent());
113
-
return;
111
+
if (barcode.data==null||!barcode.data.startsWith("09:")) {
112
+
overlay.brush =Brush.transparent()
113
+
return
114
114
}
115
115
...
116
116
```
@@ -125,30 +125,25 @@ In Android, the user must explicitly grant permission for each app to access cam
125
125
126
126
When using the built-in camera there are recommended settings for each capture mode. These must be used to achieve the best performance and user experience for the respective mode. The following code shows how to get the recommended settings and create the camera:
val cameraSettings =BarcodeCapture.createRecommendedCameraSettings()
130
130
131
131
// Depending on the use case further camera settings adjustments can be made here.
132
132
133
-
Camera camera =Camera.getDefaultCamera();
134
-
135
-
if (camera !=null) {
136
-
camera.applySettings(cameraSettings);
137
-
}
133
+
val camera =Camera.getDefaultCamera()
134
+
camera?.applySettings(cameraSettings)
138
135
```
139
136
140
137
Because the frame source is configurable, the data capture context must be told which frame source to use. This is done with a call to [DataCaptureContext.setFrameSource()](https://docs.scandit.com/data-capture-sdk/android/core/api/data-capture-context.html#method-scandit.datacapture.core.DataCaptureContext.SetFrameSourceAsync)
141
138
142
-
```java
143
-
dataCaptureContext.setFrameSource(camera);
139
+
```kotlin
140
+
dataCaptureContext.frameSource =camera
144
141
```
145
142
146
143
The camera is off by default and must be turned on. This is done by calling [FrameSource.switchToDesiredState()](https://docs.scandit.com/data-capture-sdk/android/core/api/frame-source.html#method-scandit.datacapture.core.IFrameSource.SwitchToDesiredStateAsync) with a value of [FrameSourceState.ON](https://docs.scandit.com/data-capture-sdk/android/core/api/frame-source.html#value-scandit.datacapture.core.FrameSourceState.On):
147
144
148
-
```java
149
-
if (camera !=null) {
150
-
camera.switchToDesiredState(FrameSourceState.ON);
151
-
}
145
+
```kotlin
146
+
camera?.switchToDesiredState(FrameSourceState.ON)
152
147
```
153
148
154
149
:::note
@@ -161,15 +156,15 @@ When using the built-in camera as frame source, you may want to display the came
161
156
162
157
To do that, add a [DataCaptureView](https://docs.scandit.com/data-capture-sdk/android/core/api/ui/data-capture-view.html#class-scandit.datacapture.core.ui.DataCaptureView) to your view hierarchy:
val dataCaptureView =DataCaptureView.newInstance(this, dataCaptureContext)
161
+
setContentView(dataCaptureView)
167
162
```
168
163
169
164
To visualize the results of barcode scanning, the following [overlay](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/ui/barcode-capture-overlay.html#class-scandit.datacapture.barcode.ui.BarcodeCaptureOverlay) can be added:
@@ -67,26 +67,26 @@ With the context you can then instantiate a [`QRCodeBarcodeGeneratorBuilder`](ht
67
67
68
68
You can configure the colors used in the resulting image, and the two settings that can be configured for QR codes: [`QRCodeBarcodeGeneratorBuilder.errorCorrectionLevel`](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/barcode-generator-builder.html#method-scandit.datacapture.barcode.generator.QrCodeBarcodeGeneratorBuilder.WithErrorCorrectionLevel) and [`QRCodeBarcodeGeneratorBuilder.versionNumber`](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/barcode-generator-builder.html#method-scandit.datacapture.barcode.generator.QrCodeBarcodeGeneratorBuilder.WithVersionNumber).
0 commit comments