BlinkReceiptSdk
Static entry point for SDK initialization and global configuration. By default the SDK initializes itself at app startup through androidx.startup, reading the license key from your manifest; call initialize() yourself only if you disabled auto-initialization (see Initialization).
Package: com.microblink
Declaration
// Java: public final class BlinkReceiptSdk — all members are static; the class cannot be instantiated.
class BlinkReceiptSdk
Quick Reference
Methods
| Method | Description |
|---|---|
initialize(context) | Initializes the SDK with the license key from the manifest |
initialize(context, callback) | Initializes the SDK with the license key from the manifest and reports the result |
initialize(context, licenseKey, callback) | Initializes the SDK with a license key passed in code |
terminate() | Shuts down the native recognizer and releases its resources |
Properties
| Property | Description |
|---|---|
licenseKey() | License key the SDK was initialized with |
licenseeName() | Licensee name from the manifest |
productIntelligenceKey() | Product Intelligence key |
clientUserId() | Optional client-supplied user identifier |
initialized() | Whether the SDK has been initialized |
onDeviceOcr() | Whether OCR runs on the device |
onDeviceMinSdkVersion | Minimum Android API level for on-device OCR |
googleApiKey() | Google Places API key |
webApiKey() | Web API key |
yelpApiKey() | Yelp API key |
scanType() | Scan type reported for scans |
frameResults() | Whether per-frame results are produced |
daysToStoreScan(context) | Number of days completed scans are kept on the device |
cpuPowerIndex() | CPU performance metric for this device |
versionName(context) | SDK version name string |
versionCode(context) | SDK version code string |
packageName(context) | Application package name |
Methods
initialize(context)
fun initialize(context: Context)
Initializes the SDK with the license key from the com.microblink.LicenseKey meta-data entry in AndroidManifest.xml. This is the call the SDK's androidx.startup initializer makes. It reports no result: a missing or invalid key, or any other initialization failure, is only logged. Use initialize(context, callback) to receive the outcome.
initialize(context, callback)
fun initialize(context: Context, callback: InitializeCallback)
Reads the SDK's meta-data entries from AndroidManifest.xml (license key, Product Intelligence key, client user ID, licensee name, Google Places, Yelp and web API keys, com.microblink.OnDeviceOcr, com.microblink.FrameResults), then initializes the SDK. If no license key is found, initialization stops and callback.onException() receives an exception with the message "license key not found in your manifest!".
InitializeCallback (com.microblink.core) has two methods:
| Method | Called when |
|---|---|
onComplete() | Initialization succeeded and the license check has finished |
onException(throwable: Throwable) | Initialization failed, for example because the license key is missing or invalid, or the native library could not be loaded |
initialize(context, licenseKey, callback)
fun initialize(context: Context, licenseKey: String, callback: InitializeCallback)
Initializes the SDK with a license key passed in code instead of the manifest. An empty key fails with callback.onException(). This overload does not read the manifest meta-data entries itself; if you disabled auto-initialization, set any other keys (for example productIntelligenceKey()) in code.
terminate()
fun terminate()
Shuts down the native recognizer and releases its resources.
Properties
licenseKey()
fun licenseKey(): String?
The license key the SDK was initialized with. There is no setter: the key comes from the com.microblink.LicenseKey manifest entry or from initialize(context, licenseKey, callback).
licenseeName()
fun licenseeName(): String?
The licensee name, read from the com.microblink.LicenseeName manifest entry.
productIntelligenceKey()
fun productIntelligenceKey(): String?
fun productIntelligenceKey(productIntelligenceKey: String)
Product Intelligence key. Required for enriched product data (name, brand, category, UPC). Also read from the com.microblink.ProductIntelligence manifest entry.
clientUserId()
fun clientUserId(): String?
fun clientUserId(clientUserId: String)
Optional client-supplied user identifier for mapping scan data to your own user records. Also read from the com.microblink.ClientUserId manifest entry.
initialized()
fun initialized(): Boolean
Returns true once initialize() has unlocked the SDK successfully.
onDeviceOcr()
fun onDeviceOcr(): Boolean
fun onDeviceOcr(onDeviceOcr: Boolean)
Whether OCR runs on the device (true) or on the server (false).
Default: true on devices running API onDeviceMinSdkVersion or higher, false otherwise. During initialize() the SDK then sets it from the device's measured performance: true when cpuPowerIndex() is at least 35. That replaces any value read from the com.microblink.OnDeviceOcr manifest entry, so to force a value call onDeviceOcr(Boolean) after initialization.
onDeviceMinSdkVersion
const val onDeviceMinSdkVersion: Int = 24 // Build.VERSION_CODES.N
Minimum Android API level required for on-device OCR.
googleApiKey()
fun googleApiKey(): String?
fun googleApiKey(googleApiKey: String)
Google Places API key, used for place and merchant lookup. Also read from the com.microblink.GooglePlacesKey manifest entry.
webApiKey()
fun webApiKey(): String?
fun webApiKey(key: String)
Web API key for server-side requests such as promotion validation and duplicate detection. Also read from the com.microblink.WebApiKey manifest entry.
yelpApiKey()
fun yelpApiKey(): String?
fun yelpApiKey(yelpApiKey: String)
Yelp API key. Also read from the com.microblink.YelpKey manifest entry.
scanType()
fun scanType(): ScanType
fun scanType(type: ScanType)
Scan type reported for scans. ScanType values are VIDEO_DEVICE and USER_DEVICE. After licensing, the SDK may update it from your account's scan settings.
Default: ScanType.VIDEO_DEVICE
frameResults()
fun frameResults(): Boolean
fun frameResults(frameResults: Boolean)
Whether to produce per-frame results during scanning. Also read from the com.microblink.FrameResults manifest entry.
Default: false
daysToStoreScan(context)
fun daysToStoreScan(context: Context): Int?
fun daysToStoreScan(context: Context, days: Int)
Number of days completed scans are kept on the device. Scans are stored only when this is greater than 0; scans older than this are deleted during initialize(). The getter returns null when no value has been set.
cpuPowerIndex()
fun cpuPowerIndex(): Float
CPU performance metric for this device, measured during initialize(). Used to choose the default for onDeviceOcr().
Default: -1 until measured, or if the measurement fails.
versionName(context)
fun versionName(context: Context): String
SDK version name string. Empty if it cannot be read.
versionCode(context)
fun versionCode(context: Context): String
SDK version code string. Empty if it cannot be read.
packageName(context)
fun packageName(context: Context): String
Returns the application package name.