On this page

Stuck? Open a support ticket and the barKoder team will help. Open a ticket

Installation

To utilize our SDK on Android, follow these simple steps to integrate it into your Android project.

1. Add the package #

Import barkoder as module in Groovy DSL #

Import Module #

Start by importing the 'barkoder' module as displayed in the instructions.

Please note, the source directory path should refer to the 'barcoder' folder that contains both 'barkoder.aar' and 'build.gradle', not directly to the 'barkoder.aar' file.

Import barKoder as module in Groovy DSL
Import barKoder as module in Groovy DSL


Keep in mind that path in source directory should reference to the barcoder folder that contains both barkoder.aar and build.gradle, not directly to the barkoder.aar file

Add Dependency #

In your app's build gradle file, add the following dependency:



Add dependency for barKoder
Add dependency for barKoder


Kotlin
implementation project(path: ':barkoder')


Import barkoder  in Kotlin DSL Gradle (Android) #

Create libs folder in ur app directory #

<br>

Put barkoder.aar in libs folder #

<br>

Add to build.gradle.kts (Module :app): #

Gradle
implementation(files("libs/barkoder.aar"))

2. Add the scanner view #

Add Activity/Fragment #

In the layout.xml of the activity/fragment where you want the scanner to be visible, add the following code:


Add activity/fragment
Add activity/fragment


XML-DOC
<com.barkoder.BarkoderView
        android:id="@+id/bkdView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />


3. Set the license key and barcode types #

Create Barkoder Config #

Create a 'barkoder' configuration as per your requirements or choose from our templates.

Kotlin
bkdView.config = BarkoderConfig(this, "LICENSE_KEY") {
   Log.i("LicenseInfo", it.message)
}
BarkoderHelper.applyConfigSettingsFromTemplate(
   this,
   bkdView.config,
   BarkoderConfigTemplate.INDUSTRIAL_1D,
   null
)

Enabling Symbologies #

The following method can be used in order to enable individual symbologies from setActiveBarcodeTypes.

( There is option to set multiple active barcodes at once as array )
Kotlin
private fun setActiveBarcodeTypes() {
    // There is option to set multiple active barcodes at once as array
    bkdView.config.decoderConfig.SetEnabledDecoders(
        arrayOf(
            Barkoder.DecoderType.QR,
            Barkoder.DecoderType.Ean13,
            Barkoder.DecoderType.IDDocument // enable mrz
        )
    )
    // or configure them one by one
    bkdView.config.decoderConfig.UpcA.enabled = true
}

This comprehensive guide should enable a smooth integration of our SDK into your Android project. For any further assistance, feel free to reach out by utilizing the Ticketing System of the barKoder Developer Portal.

Licensing #

The SDK will scan barcodes even without a license, but results will come with an "(Unlicensed)" prefix.If you want to test the SDK today create a trial license https://barkoder.com/request-quote or just sign-up at barkoder.com/register to access all barKoder features.

4. Start scanning and read results #

Add BarkoderResultCallback #

Implement the 'BarkoderResultCallback' interface to receive scanned results.

Kotlin
class MainActivity : AppCompatActivity(), BarkoderResultCallback {
   ....

   override fun scanningFinished(results: Array<Barkoder.Result>, thumbnails: Array<Bitmap>, imageResult: Bitmap?) {
       Log.i("Scanned result", results[0].textualData)
   }
}

Start Scanning #

Finally, initiate the scanning process with the following command:

Kotlin
bkdView.startScanning(this)