Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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.

```java
DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
```kotlin
val dataCaptureContext = DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --")
```
2 changes: 1 addition & 1 deletion docs/sdks/android/add-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ Check [the official provider documentation](https://developer.android.com/guide/

import OSSLicense from '../../partials/_third-party-licenses.mdx';

<OSSLicense/>
<OSSLicense/>
18 changes: 7 additions & 11 deletions docs/sdks/android/agents-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ override fun onPause() { sparkView.onPause(); super.onPause() }
// Listen for results
sparkScan.addListener(object : SparkScanListener {
override fun onBarcodeScanned(spark: SparkScan, session: SparkScanSession, data: FrameData?) {
val barcode = session.newlyRecognizedBarcode.firstOrNull()
val barcode = session.newlyRecognizedBarcode
barcode?.let { /* handle on UI thread */ }
}
})
Expand Down Expand Up @@ -142,13 +142,10 @@ val overlay = BarcodeCaptureOverlay.newInstance(barcodeCapture, captureView)

barcodeCapture.addListener(object : BarcodeCaptureListener {
override fun onBarcodeScanned(mode: BarcodeCapture, session: BarcodeCaptureSession, data: FrameData?) {
val code = session.newlyRecognizedBarcodes.firstOrNull()?.data
val code = session.newlyRecognizedBarcode?.data
// handle result
}
})

override fun onResume() { super.onResume(); captureView.onResume() }
override fun onPause() { captureView.onPause(); super.onPause() }
```

---
Expand Down Expand Up @@ -207,7 +204,7 @@ Typical flow:

Kotlin sketch:
```kotlin
val labelSettings = LabelCaptureSettings(/* configure with your label definition */)
val labelSettings = LabelCaptureSettings.builder()/* configure with your label definition */.build()
val labelCapture = LabelCapture.forDataCaptureContext(dataCaptureContext, labelSettings)

val captureView = DataCaptureView.newInstance(context, dataCaptureContext)
Expand All @@ -218,7 +215,7 @@ val validationOverlay = LabelCaptureValidationFlowOverlay.newInstance(

labelCapture.addListener(object : LabelCaptureListener {
override fun onLabelCaptured(capture: LabelCapture, session: LabelCaptureSession, data: FrameData?) {
val fields = session.newlyCapturedLabels.firstOrNull()?.fields
val fields = session.capturedLabels.firstOrNull()?.fields
// Extract required field values
}
})
Expand All @@ -237,7 +234,7 @@ labelCapture.addListener(object : LabelCaptureListener {
Kotlin outline:
```kotlin
val idSettings = IdCaptureSettings().apply {
supportedDocuments = EnumSet.of(SupportedDocuments.IdentityCard, SupportedDocuments.DLVIZ)
acceptedDocuments = listOf(IdCard(IdCaptureRegion.ANY), DriverLicense(IdCaptureRegion.ANY))
// Configure sides/regions as required
}
val idCapture = IdCapture.forDataCaptureContext(dataCaptureContext, idSettings)
Expand All @@ -246,8 +243,7 @@ val captureView = DataCaptureView.newInstance(context, dataCaptureContext)
val overlay = IdCaptureOverlay.newInstance(idCapture, captureView)

idCapture.addListener(object : IdCaptureListener {
override fun onIdCaptured(mode: IdCapture, session: IdCaptureSession, data: FrameData?) {
val capturedId = session.newlyCapturedId
override fun onIdCaptured(mode: IdCapture, id: CapturedId) {
// Consume fields (name, DOB, document number, etc.)
}
})
Expand Down Expand Up @@ -321,4 +317,4 @@ import com.scandit.datacapture.label.*
import com.scandit.datacapture.label.ui.*
import com.scandit.datacapture.id.*
import com.scandit.datacapture.id.ui.*
```
```
40 changes: 20 additions & 20 deletions docs/sdks/android/barcode-capture/configure-barcode-symbologies.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import EnableSymbologies from '../../../partials/configure-symbologies/_enable-s

The following code shows how to enable scanning Code 128 codes for Barcode Capture:

```java
BarcodeCaptureSettings settings = new BarcodeCaptureSettings();
settings.enableSymbology(Symbology.CODE128, true);
```kotlin
val settings = BarcodeCaptureSettings()
settings.enableSymbology(Symbology.CODE128, true)
```

import CapturePresents from '../../../partials/configure-symbologies/_capture-presents.mdx'
Expand All @@ -40,11 +40,11 @@ If you want to read codes that are shorter/longer than the specified default ran

The below code shows how to change the active symbol count for Code 128 to read codes with 6, 7 and 8 symbols.

```java
BarcodeCaptureSettings settings = new BarcodeCaptureSettings();
SymbologySettings symbologySettings = settings.getSymbologySettings(Symbology.CODE128);
HashSet<Short> activeSymbolCounts = new HashSet<>(Arrays.asList(new Short[] { 6, 7, 8}));
symbologySettings.setActiveSymbolCounts(activeSymbolCounts);
```kotlin
val settings = BarcodeCaptureSettings()
val symbologySettings = settings.getSymbologySettings(Symbology.CODE128)
val activeSymbolCounts = mutableSetOf<Short>(6, 7, 8)
symbologySettings.activeSymbolCounts = activeSymbolCounts
```

import CalculateSymbolCount from '../../../partials/configure-symbologies/_calculate-symbol-count.mdx'
Expand All @@ -61,10 +61,10 @@ When you enable a symbology as described above, only dark-on-bright codes are en

The following code shows how to enable color-inverted reading for Code 128:

```java
BarcodeCaptureSettings settings = new BarcodeCaptureSettings();
SymbologySettings symbologySettings = settings.getSymbologySettings(Symbology.CODE128);
symbologySettings.setColorInvertedEnabled(true);
```kotlin
val settings = BarcodeCaptureSettings()
val symbologySettings = settings.getSymbologySettings(Symbology.CODE128)
symbologySettings.isColorInvertedEnabled = true
```

## Enforce Checksums
Expand All @@ -75,10 +75,10 @@ When enabling a checksum you have to make sure that the data of your codes conta

You can enforce a specific checksum by setting it through `SymbologySettings.checksums`:

```java
BarcodeCaptureSettings settings = new BarcodeCaptureSettings();
SymbologySettings symbologySettings = settings.getSymbologySettings(Symbology.CODE39);
symbologySettings.setChecksums(EnumSet.of(Checksum.MOD43));
```kotlin
val settings = BarcodeCaptureSettings()
val symbologySettings = settings.getSymbologySettings(Symbology.CODE39)
symbologySettings.checksums = EnumSet.of(Checksum.MOD43)
```

## Enable Symbology-Specific Extensions
Expand All @@ -91,10 +91,10 @@ To enable/disable a symbology extension, use `SymbologySettings.setExtensionEnab

The following code shows how to enable the full ASCII extension for Code 39.

```java
BarcodeCaptureSettings settings = new BarcodeCaptureSettings();
SymbologySettings symbologySettings = settings.getSymbologySettings(Symbology.CODE39);
symbologySettings.setExtensionEnabled("full_ascii", true);
```kotlin
val settings = BarcodeCaptureSettings()
val symbologySettings = settings.getSymbologySettings(Symbology.CODE39)
symbologySettings.setExtensionEnabled("full_ascii", true)
```

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.
77 changes: 36 additions & 41 deletions docs/sdks/android/barcode-capture/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ Barcode scanning is orchestrated by the [BarcodeCapture data capture mode](https

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).

```java
BarcodeCaptureSettings settings = new BarcodeCaptureSettings();
settings.enableSymbology(Symbology.CODE128, true);
settings.enableSymbology(Symbology.CODE39, true);
settings.enableSymbology(Symbology.QR, true);
settings.enableSymbology(Symbology.EAN8, true);
settings.enableSymbology(Symbology.UPCE, true);
settings.enableSymbology(Symbology.EAN13_UPCA, true);
```kotlin
val settings = BarcodeCaptureSettings().apply {
enableSymbology(Symbology.CODE128, true)
enableSymbology(Symbology.CODE39, true)
enableSymbology(Symbology.QR, true)
enableSymbology(Symbology.EAN8, true)
enableSymbology(Symbology.UPCE, true)
enableSymbology(Symbology.EAN13_UPCA, true)
}
```

:::note
Expand All @@ -72,8 +73,8 @@ If you are not disabling barcode capture immediately after having scanned the fi

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:

```java
barcodeCapture = BarcodeCapture.forDataCaptureContext(dataCaptureContext, settings);
```kotlin
val barcodeCapture = BarcodeCapture.forDataCaptureContext(dataCaptureContext, settings)
```

## Register the Barcode Capture Listener
Expand All @@ -82,22 +83,21 @@ To get informed whenever a new code has been recognized, add a [BarcodeCaptureLi

First conform to the `BarcodeCaptureListener` interface. For example:

```java
@Override
public void onBarcodeScanned(
@NonNull BarcodeCapture barcodeCapture,
@NonNull BarcodeCaptureSession session,
@NonNull FrameData frameData
```kotlin
override fun onBarcodeScanned(
barcodeCapture: BarcodeCapture,
session: BarcodeCaptureSession,
frameData: FrameData
) {
Barcode recognizedBarcode = session.getNewlyRecognizedBarcode();
val recognizedBarcodes = session.newlyRecognizedBarcode
// Do something with the barcodes. See Rejecting Barcodes, below, for an example.
}
```

Then add the listener:

```java
barcodeCapture.addListener(this);
```kotlin
barcodeCapture.addListener(this)
```

### Rejecting Barcodes
Expand All @@ -106,11 +106,11 @@ To prevent scanning unwanted codes, you can reject them by adding the desired lo

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:

```java
```kotlin
...
if (barcode.getData() == null || !barcode.getData().startsWith("09:")) {
overlay.setBrush(Brush.transparent());
return;
if (barcode.data == null || !barcode.data.startsWith("09:")) {
overlay.brush = Brush.transparent()
return
}
...
```
Expand All @@ -125,30 +125,25 @@ In Android, the user must explicitly grant permission for each app to access cam

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:

```java
CameraSettings cameraSettings = BarcodeCapture.createRecommendedCameraSettings();
```kotlin
val cameraSettings = BarcodeCapture.createRecommendedCameraSettings()

// Depending on the use case further camera settings adjustments can be made here.

Camera camera = Camera.getDefaultCamera();

if (camera != null) {
camera.applySettings(cameraSettings);
}
val camera = Camera.getDefaultCamera()
camera?.applySettings(cameraSettings)
```

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)

```java
dataCaptureContext.setFrameSource(camera);
```kotlin
dataCaptureContext.setFrameSource(camera)
```

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):

```java
if (camera != null) {
camera.switchToDesiredState(FrameSourceState.ON);
}
```kotlin
camera?.switchToDesiredState(FrameSourceState.ON)
```

:::note
Expand All @@ -161,15 +156,15 @@ When using the built-in camera as frame source, you may want to display the came

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:

```java
DataCaptureView dataCaptureView = DataCaptureView.newInstance(this, dataCaptureContext);
setContentView(dataCaptureView);
```kotlin
val dataCaptureView = DataCaptureView.newInstance(this, dataCaptureContext)
setContentView(dataCaptureView)
```

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:

```java
BarcodeCaptureOverlay overlay = BarcodeCaptureOverlay.newInstance(barcodeCapture, dataCaptureView);
```kotlin
val overlay = BarcodeCaptureOverlay.newInstance(barcodeCapture, dataCaptureView)
```

## Disabling Barcode Capture
Expand Down
38 changes: 19 additions & 19 deletions docs/sdks/android/barcode-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ With the context you can then instantiate a [`BarcodeGeneratorBuilder`](https://

You can configure the colors used in the resulting image:

```java
DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey(licenseKey);
BarcodeGenerator.Code128BarcodeGeneratorBuilder builder = BarcodeGenerator.code128BarcodeGeneratorBuilder(dataCaptureContext)
```kotlin
val dataCaptureContext = DataCaptureContext.forLicenseKey(licenseKey)
val builder = BarcodeGenerator.code128BarcodeGeneratorBuilder(dataCaptureContext)
.withBackgroundColor(Color.WHITE)
.withForegroundColor(Color.BLACK);
.withForegroundColor(Color.BLACK)
```

When the builder is configured get the `BarcodeGenerator` and try to generate the image:

```java
```kotlin
try {
BarcodeGenerator generator = builder.build();
Bitmap image = generator.generate(dataString, 200);
val generator = builder.build()
val image = generator.generate(dataString, 200)
// Use the image
} catch (Exception exception) {
} catch (exception: Exception) {
// Handle the error
exception.printStackTrace();
exception.printStackTrace()
}
```

Expand All @@ -67,26 +67,26 @@ With the context you can then instantiate a [`QRCodeBarcodeGeneratorBuilder`](ht

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).

```java
DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey(licenseKey);
BarcodeGenerator.QrCodeBarcodeGeneratorBuilder builder = new BarcodeGenerator.QrCodeBarcodeGeneratorBuilder(dataCaptureContext)
```kotlin
val dataCaptureContext = DataCaptureContext.forLicenseKey(licenseKey)
val builder = BarcodeGenerator.qrCodeBarcodeGeneratorBuilder(dataCaptureContext)
.withBackgroundColor(Color.WHITE)
.withForegroundColor(Color.BLACK)
.withErrorCorrectionLevel(QrCodeErrorCorrectionLevel.MEDIUM)
.withVersionNumber(4);
.withVersionNumber(4)
```

When the builder is configured get the `BarcodeGenerator` and try to generate the image:

```java
```kotlin
try {
BarcodeGenerator generator = builder.build();
Bitmap image = generator.generate(dataString, 200);
val generator = builder.build()
val image = generator.generate(dataString, 200)
// Use the image
} catch (Exception exception) {
} catch (exception: Exception) {
// Handle the error
exception.printStackTrace();
exception.printStackTrace()
}
```

See the complete [API reference](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/barcode-generator.html) for more information.
See the complete [API reference](https://docs.scandit.com/data-capture-sdk/android/barcode-capture/api/barcode-generator.html) for more information.
Loading