Skip to main content

SDK Initialization | Android Document Scanner

License Key#

In order to run the Scanbot SDK functionality within your production app, you have to purchase and use a valid Scanbot SDK license.

Each license key is valid only for a given app bundle identifier. You will be unable to use any of the SDK features if the license key is corrupted, expired or invalid in any other way.

Trial License#

The Scanbot SDK will run without a license for one minute per session! To get an unrestricted, "no-strings-attached" 30-day trial license, please submit the Trial License Form on our website.

Please kindly note that a trial license can only be used in a development and staging environment. You are not allowed to publish your app to the App Store, Play Store or any 3rd party Android App Store with a trial license.

Purchase a Production License#

To get pricing information and purchase a production license for the Scanbot SDK please request a quote.

Initialize#

The Scanbot SDK must be initialized before usage. Add the following code snippets to your Application class:

import io.scanbot.sdk.ScanbotSDKInitializer
override fun onCreate() {    super.onCreate()
    ScanbotSDKInitializer()      .license(this, LICENSE_KEY) // see below      .initialize(this)}

Please make sure to use the ScanbotSDKInitializer class from the new Java package io.scanbot.sdk. (net.doo.snap.ScanbotSDKInitializer is deprecated).

Add Scanbot SDK License Key#

Use the method license(application, "YOUR_SCANBOT_SDK_LICENSE_KEY") on initialization of the Scanbot SDK to set your license key:

// This is an expired license key. Used only for demo code purposes!const val LICENSE_KEY =    "MiKudIf/IFGnwk/0ZQAhx58IGEV8/L" +    "d6dF/F/j2TyLNNb+TCaIsQLOf2+/Ih" +    "LRRPvRsHESA/b0KFqnxYl4briv3kzQ" +    "tSTrvDJ9mE15rxU/Pob4XRnjTSc9B7" +    "P/CpM0HDkmM02U8ljt0kKwpQSRZkiz" +    "rBe+qttmA0b00ZEcyfn9t2xP4zRdaD" +    "ayjWAdZi82oP3UST3bLIV8I90Qordf" +    "s+u23JKL52bQY+HB1HNW7Ow8rA4+Mg" +    "Lr/wE2N+UBElHPOZLtQBTHYUvbVwVU" +    "KZDWOEv8VfrTmn2XA0tKVSDaxL6z7B" +    "1s2g83XWYaxXrf4A3q/fkSNvDN1oic" +    "Dvs0gbD1Lf0w==\nU2NhbmJvdFNESw" +    "ppby5zY2FuYm90LmV4YW1wbGUuc2Rr" +    "LmFuZHJvaWQKMTQ3ODA0NDc5OQoyCj" +    "I=\n"
ScanbotSDKInitializer()        .license(this, LICENSE_KEY)        .initialize(this)

The Scanbot SDK license key is bound to the applicationId, which can be found in the app-level build.gradle file of your app. Please note that the applicationId is the actual and relevant ID of an app. The "package" in the AndroidManifest.xml as well as the Java package are NOT relevant (also see the Android documentation).

Please make sure that you have inserted the exact key as it is stated in the license file - with all encoded line breaks \n.

License Checks in Production Apps#

caution

If your Scanbot SDK license has expired, any call to the Scanbot SDK API will return empty results. To prevent this you should always check for license expiration during the runtime via licenseInfo.isValid. If this property returns false, you should disable any usage of the Scanbot SDK (functions, UI components, etc).

To handle License errors properly the IScanbotSDKLicenseErrorHandler can be used. The callback will be triggered if any license error has occurred. Use the following snippet to initialize Scanbot with a callback.

import io.scanbot.sdk.ScanbotSDK
ScanbotSDKInitializer()    .withLogging(true)    .license(this, LICENSE_KEY)    .licenceErrorHandler(IScanbotSDKLicenseErrorHandler { status, feature, message ->        // Handle license errors here:        LoggerProvider.logger.d("ExampleApplication", "license status:${status.name}, message: $message")        if (feature != SdkFeature.NoSdkFeature) {            LoggerProvider.getLogger().d("ExampleApplication", "Missing SDK feature in license: ${feature.name}")        }    })    .initialize(this)

We highly recommend implementing a suitable handling of this case in your app!

Example code for checking the license status:

import io.scanbot.sdk.ScanbotSDK
// Check the license status:val licenseInfo = ScanbotSDK(activity).licenseInfoLoggerProvider.getLogger().d("ExampleApplication", "License status: ${licenseInfo.status}")LoggerProvider.getLogger().d("ExampleApplication", "License isValid: ${licenseInfo.isValid}")LoggerProvider.getLogger().d("ExampleApplication", "License message: ${licenseInfo.licenseStatusMessage}")
if (licenseInfo.isValid) {    // Making your call into ScanbotSDK API is safe now.    // e.g. start barcode scanner}