# Symbologies

Manage barcode symbology settings on Socket Mobile scanners using CaptureSDK. Enable or disable specific barcode types (e.g., EAN-13, Code 128, QR Code, UPC-A) to avoid scanning the wrong barcode when multiple symbologies are nearby. Symbology settings persist on the scanner. Covers reading current symbology status before toggling, enabling a symbology, and disabling a symbology. See the Data Sources appendix for the full list of symbology IDs. Includes code samples.

In the event where there are several type of barcodes close to each other and to avoid scanning the wrong barcode, it might be useful to enable only the barcode symbology or symbologies the application needs. Enabling or Disabling a Barcode Symbology persists in the Scanner. It is best to first read if the Symbology is already enabled before trying to enable it.

The list of symbologies with their Ids is available at [this page](/docs/appendix/data-sources).

## Getting the Status of a Symbology

Here is a code showing how to get a specific Symbology status:

## Java

```java
// Getting status for Code 128 symbology
device.getDataSourceStatus(DataSource.ID_CODE_128, new PropertyCallback() {
    @Override
    public void onComplete(CaptureError captureError, Property property) {
        if (captureError != null) {
            Log.e("Symbology", "Get failed: " + captureError.getMessage());
            return;
        }
        switch (property.getDataSource().getStatus()) {
            case DataSource.STATUS_ENABLED:
                Log.d("Symbology", "Symbology is enabled");
                break;
            case DataSource.STATUS_DISABLED:
                Log.d("Symbology", "Symbology is disabled");
                break;
            case DataSource.STATUS_NOT_SUPPORTED:
                Log.d("Symbology", "Symbology is not supported on this device");
                break;
        }
    }
});
```

## Kotlin

```kotlin
// Getting status for Code 128 symbology
device.getDataSourceStatus(DataSource.ID_CODE_128) { captureError, property ->
    if (captureError != null) {
        Log.e("Symbology", "Get failed: ${captureError.message}")
        return@getDataSourceStatus
    }
    when (property.dataSource.status) {
        DataSource.STATUS_ENABLED -> Log.d("Symbology", "Symbology is enabled")
        DataSource.STATUS_DISABLED -> Log.d("Symbology", "Symbology is disabled")
        DataSource.STATUS_NOT_SUPPORTED -> Log.d("Symbology", "Symbology is not supported on this device")
    }
}
```

## Swift

```swift
// Getting status for Code 128 symbology
device.getDataSourceInfoFromId(.symbologyCode128) { result, dataSourceInfo in
    if let symbology = dataSourceInfo {
        if symbology.status == .enable {
            print("Symbology is enabled")
        } else if symbology.status == .disable {
            print("Symbology is disabled")
        } else if symbology.status == .notSupported {
            print("Symbology is not supported on this device")
        }
    }
}
```

## C#

```csharp
// Getting status for Code 128 symbology
int symbologyId = ICaptureDataSource.Id.kSymbologyCode128;
CaptureHelperDevice.DataSourceResult result = await device.GetDataSourceAsync(symbologyId);

if (result.IsSuccessful())
{
    if (result.Status == CaptureHelperDevice.DataSourceResult.eStatus.enable)
    {
        Console.WriteLine("Symbology is enabled");
    }
    else if (result.Status == CaptureHelperDevice.DataSourceResult.eStatus.disable)
    {
        Console.WriteLine("Symbology is disabled");
    }
}
```

## Dart

```dart
// Getting status for Code 128 symbology
final DataSource code128 = await device.getDataSource(
  CaptureDataSourceID.symbologyCode128,
);

if (code128.status == CaptureDataSourceStatus.enable) {
  debugPrint('Symbology is enabled');
} else if (code128.status == CaptureDataSourceStatus.disable) {
  debugPrint('Symbology is disabled');
} else if (code128.status == CaptureDataSourceStatus.notSupported) {
  debugPrint('Symbology is not supported on this device');
}
```

## JavaScript

```javascript
// Getting status for Code 128 symbology
const dataSource = await device.getDataSource(
    CaptureDataSourceID.SymbologyCode128
);

if (dataSource.status === CaptureDataSourceStatus.Enable) {
    console.log('Symbology is enabled');
} else if (dataSource.status === CaptureDataSourceStatus.Disable) {
    console.log('Symbology is disabled');
}
```

## Enabling or Disabling a Symbology

## Java

```java
PropertyCallback mSetPropertyCallback = new PropertyCallback() {
    @Override
    public void onComplete(CaptureError captureError, Property property) {
        if (captureError != null) {
            Log.e("Symbology", "Set failed: " + captureError.getMessage());
        }
    }
};

// Enable Code 128 symbology
device.enableDataSource(DataSource.ID_CODE_128, mSetPropertyCallback);

// Disable UPC-A symbology
device.disableDataSource(DataSource.ID_UPC_A, mSetPropertyCallback);
```

## Kotlin

```kotlin
val mSetPropertyCallback = PropertyCallback { captureError, _ ->
    if (captureError != null) {
        Log.e("Symbology", "Set failed: ${captureError.message}")
    }
}

// Enable Code 128 symbology
device.enableDataSource(DataSource.ID_CODE_128, mSetPropertyCallback)

// Disable UPC-A symbology
device.disableDataSource(DataSource.ID_UPC_A, mSetPropertyCallback)
```

## Swift

```swift
// Setting status for Code 128 symbology to enabled

let symbology: SKTCaptureDataSource = SKTCaptureDataSource()
symbology.id = .symbologyCode128
symbology.status = .enable

device.setDataSourceInfo(symbology) { result in
    print("Set symbology - \(symbology.name ?? ""): \(result.rawValue)")
}
```

## C#

```csharp
// Setting status for Code 128 symbology to enabled
int symbologyId = ICaptureDataSource.Id.kSymbologyCode128;
CaptureHelper.AsyncResult result = await device.SetDataSourceAsync(symbologyId, true);

if (!result.IsSuccessful())
{
    Console.WriteLine("Unable to change the symbology state: " + result.Result);
}
```

## Dart

```dart
// Setting status for Code 128 symbology to enabled
await device.setDataSource(
  CaptureDataSourceID.symbologyCode128,
  status: CaptureDataSourceStatus.enable,
);

// Setting status for Code 128 symbology to disabled
await device.setDataSource(
  CaptureDataSourceID.symbologyCode128,
  status: CaptureDataSourceStatus.disable,
);
```

## JavaScript

```javascript
// Setting status for Code 128 symbology to enabled
await device.setDataSource(
    CaptureDataSourceID.SymbologyCode128,
    CaptureDataSourceStatus.Enable
);

// Setting status for Code 128 symbology to disabled
await device.setDataSource(
    CaptureDataSourceID.SymbologyCode128,
    CaptureDataSourceStatus.Disable
);
```