For a first scan without building a camera screen, use the ZIP's standalone sample and the three-step walkthrough . Java and Kotlin use the same SDK, tenant key, native engine and device license.
1. Install and get a workspace key
Download RC5 and copy a device SDK key from your workspace , using a trial or purchased seat. Follow local Maven installation . RC4 lacks the initializer used below. Declare CAMERA and INTERNET permissions and request camera access at runtime.
2. Initialize on a worker
Use the complete clientId.secret key from protected build configuration. The SDK validates it with the backend and returns the resolved tenant and device; the app does not collect login details or device IDs.
import android.content.Context;
import com.visionscan.sdk.VisionScanSdk;
import com.visionscan.sdk.VisionScanSdkConfiguration;
import com.visionscan.sdk.VisionScanSdkInitializationResult;
// Call on your I/O executor, never the Android main thread.
VisionScanSdkInitializationResult initialized = VisionScanSdk.INSTANCE.initialize(
applicationContext,
new VisionScanSdkConfiguration(
BuildConfig.VISION_SCAN_CONTROL_PLANE_ORIGIN,
BuildConfig.VISION_SCAN_SDK_API_KEY));
String tenantId = initialized.getTenantId();
String deviceId = initialized.getDeviceId();
Kotlin object methods are called through INSTANCE . Kotlin defaults do not automatically create Java overloads. Initialization handles signed-license setup; new integrations do not need a separate initializeLeaseStore / applySignedLicenseJws sequence.
3. Bind a MatrixScan session to CameraX
import com.visionscan.sdk.MatrixScanAR;
import com.visionscan.sdk.ScanMode;
import com.visionscan.sdk.VisionSessionConfig;
import com.visionscan.sdk.camerax.MatrixScanAnalyzer;
import com.visionscan.sdk.camerax.MatrixScanCameraError;
import com.visionscan.sdk.camerax.MatrixScanCameraListener;
import com.visionscan.sdk.camerax.MatrixScanCameraResult;
import java.util.Collections;
import java.util.UUID;
VisionSessionConfig config = new VisionSessionConfig(
UUID.randomUUID().toString(), tenantId, "MAIN", ScanMode.LIVE_STREAM, true, true);
MatrixScanAR session = VisionScanSdk.INSTANCE.createMatrixScanAR(config, Collections.emptySet());
MatrixScanAnalyzer analyzer = new MatrixScanAnalyzer(session, new MatrixScanCameraListener() {
@Override public void onResult(MatrixScanCameraResult frame) {
// Worker callback: frame.getResult().getAccepted() contains newly captured tracks.
// Each track provides getSymbology() and getPayload() bytes.
// On UI, mapVisibleTracks(previewView.getOutputTransform()) supplies native boundaries.
}
@Override public void onError(MatrixScanCameraError error) {
// Show one concise camera/access status; keep captured values out of system logs.
}
});
analysis.setAnalyzer(singleWorkerExecutor, analyzer);
The host supplies analysis , previewView and its executor. Use YUV_420_888 and KEEP_ONLY_LATEST; bind Preview/ImageAnalysis in one UseCaseGroup/ViewPort. The analyzer handles row/pixel stride and closes every ImageProxy. Copy the complete binding and overlay implementation from the bundled sample rather than inventing barcode boundaries. Stop/unbind the camera, close the analyzer and session, then stop its executor.
Confirm a scan and telemetry
Present a real QR/EAN barcode. Read actual native accepted tracks; no-decode frames are normal. Enable Matrix telemetry before creating sessions to see mode, symbology and acceptance counts in the same tenant workspace. The included sample already wires this through Scan with AR + telemetry .
Use troubleshooting for access, camera, dependency or telemetry problems. Android Java is an evaluation integration, not a desktop Java scanner SDK. Server clients use the experimental Cloud Java guide .
These are the callable methods and HTTP operations used by this guide. Inputs, results, lifecycle rules, and denial behavior are part of the versioned customer contract.
Android license lifecycle
The host stores only a verified device-bound lease and never constructs entitlement claims.
Validate a workspace-issued device SDK key and initialize the matching tenant/device license without collecting credentials in the app UI.
Inputs for VisionScanSdk.initialize(context: Context, configuration: VisionScanSdkConfiguration): VisionScanSdkInitializationResult
Input
Type
Required
Meaning
context
Context
Yes
Application context used to create device-bound, no-backup lease storage.
controlPlaneOrigin
HTTPS origin
Yes
Trusted VisionScan control-plane origin; HTTPS only, with no path, query, or fragment.
apiKey
device SDK API key
Yes
One-time workspace-issued device key supplied by the host application's build/configuration code, never typed into an end-user screen.
Result
Tenant and registered device IDs resolved by the backend after database-backed key validation and a verified signed-license refresh.
Lifecycle
Blocking; call on a worker. Run at app initialization and again after key rotation or device reassignment. The backend records Android manufacturer, model, device build, OS version, and API level.
Trust boundary
The tenant and device are derived from authenticated database records, never caller input. The key is sent only over HTTPS, is not logged or stored by the SDK, and should be unique and revocable per device; a client-embedded key can be extracted from the application package.
Failure behavior
Invalid, revoked, or unknown key; unentitled seat; rejected device metadata; unavailable control plane; invalid signed license; or tenant/device claim mismatch deny initialization.
VisionScanSdk.initializeLeaseStore(storageDir: File, hostDeviceId: String): Unit
method
Configure device-bound persistence used for offline grace and anti-rollback checks.
Inputs for VisionScanSdk.initializeLeaseStore(storageDir: File, hostDeviceId: String): Unit
Input
Type
Required
Meaning
storageDir
File
Yes
A host-owned no-backup directory; do not use a shared or user-exportable location.
hostDeviceId
String
Yes
The stable device identifier activated for the authenticated tenant.
Result
Replaces the process entitlement manager with one backed by the device-bound lease store.
Lifecycle
Call once after authenticated device enrollment and before applying or refreshing a license.
Trust boundary
Store verified leases only; bearer tokens remain in host-owned secure credential storage.
Failure behavior
Blank or unstable device identity prevents a durable binding.
Unreadable storage causes later lease persistence or offline checks to fail closed.
Missing, unverified, wrong-tenant, expired, revoked, or feature-incomplete entitlement throws VisionScanEntitlementDeniedException.
A missing native bridge throws VisionScanNativeUnavailableException.
VisionSession.submitFrame(width, height, format, buffer, profile?): Int
method
Compatibility entry point that submits one bounded luminance frame to the native pipeline, optionally with an explicit preprocessing profile.
Inputs for VisionSession.submitFrame(width, height, format, buffer, profile?): Int
Input
Type
Required
Meaning
width / height
Int
Yes
Positive pixel dimensions matching the normalized buffer.
format
Int
Yes
The SDK-supported image format code; CameraX integrations submit extracted luminance.
buffer
ByteArray
Yes
A stride-correct frame. Use YPlaneExtractor for padded CameraX Y planes.
profile
StillImageBatchScanProfile
No
Use liveSweep for responsive camera work or stillImageDense for licensed rescue/batch input.
Result
A native status code. It is not a barcode count; prefer processFrame for same-frame observations.
Lifecycle
Submit only while the session is open. Live mode may drop stale frames; accepted batch input must not be silently dropped.
Trust boundary
The host must bound decoded image size and must not retain or upload image bytes without policy and consent.
Failure behavior
Closed sessions throw IllegalStateException.
Invalid dimensions, format, buffer, entitlement, or native state return or throw a deterministic failure.
VisionSession.processFrame(width, height, format, buffer, profile?): VisionFrameProcessResult
method
Process one bounded luminance frame through the SDK-owned native scan pipeline and return the status plus observations from that same accepted frame.
Inputs for VisionSession.processFrame(width, height, format, buffer, profile?): VisionFrameProcessResult
Input
Type
Required
Meaning
width / height
Int
Yes
Positive pixel dimensions matching the normalized buffer.
format
Int
Yes
The SDK-supported image format code; CameraX integrations submit extracted luminance.
buffer
ByteArray
Yes
A stride-correct frame. Use YPlaneExtractor for padded CameraX Y planes.
profile
StillImageBatchScanProfile
No
Use liveSweep for responsive camera work or stillImageDense for licensed rescue/batch input.
Result
VisionFrameProcessResult(status, observations, tracking), where observations are native-decoded evidence from the same accepted frame and tracking contains native stable tracks, active/distinct/stable counts, duplicate-payload physical track count, dense-selection hints, exact target matches, pick state, and overlay-ready quadrilaterals.
Lifecycle
Use for new live and batch capture integrations. Live mode may drop stale frames by policy; accepted batch input must not be silently dropped.
Trust boundary
The host must bound decoded image size and must not retain or upload image bytes without policy and consent.
Failure behavior
Closed sessions throw IllegalStateException.
Invalid dimensions, format, buffer, entitlement, or native state return or throw a deterministic failure.
VisionSession.setFindTargets(targets: List<VisionScanTarget>): Unit
method
Install exact decoded-payload targets for SDK-owned find/pick matching.
Inputs for VisionSession.setFindTargets(targets: List<VisionScanTarget>): Unit
Input
Type
Required
Meaning
targets
List<VisionScanTarget>
Yes
Zero or more payload labels with required stable observation counts. Empty clears targets.
Result
Targets are applied to the native session tracker; subsequent processFrame results update tracking.targetMatchCount and per-track targetMatched/targetLabel.
Lifecycle
Call after session creation and before or during scanning. Targets are session-local and cleared on close.
Trust boundary
Matching is exact against deterministic decoder payloads; geometry and OCR-only rescue never synthesize a target value.
Failure behavior
Closed sessions throw IllegalStateException.
A missing native target matcher throws VisionScanNativeUnavailableException.
Return immutable observations produced by the most recently accepted frame.
Result
Zero or more BarcodeObservation values containing rawPayload, symbology, GTIN, dependent lot/expiry/serial evidence, OCR provenance, and confidence.
Lifecycle
Read after submitFrame succeeds and before the session is closed.
Trust boundary
OCR-only GTIN or serial evidence requires review and must never auto-commit; backend receipt validation remains authoritative.
Failure behavior
An empty list is a valid no-decode result.
Closed sessions throw IllegalStateException.
Malformed native observations fail deterministically instead of producing sample data.
Native MatrixScan sessions
PRXV-0122-S01: one native session owns bounded location/decode, tracks and state. Result schema: contracts/schemas/matrix-scan-result.schema.json; formats: contracts/matrix-scan-capabilities.json.
Caller-owned readable luma; fixed dimensions per session; no concurrent mutation. Maximum axis 8192 and 32000000 pixels.
Result
Typed MatrixScanResult with industry-neutral byte payloads and input-pixel quads. visibleTracks excludes lost/unstable tracks and failed-frame boxes.
Lifecycle
Synchronous worker call. Native state is session-owned; close after the operation. Do not feed accepted still/burst inputs through dropping live adapters.
Trust boundary
Verified license checked on every call. Payload is not necessarily UTF-8; counts are not backend receipt quantity.
Failure behavior
Invalid frame and decoder/capacity/cancellation statuses are explicit.
Incompatible native JSON version, encoding, mode or malformed typed result raises a redacted IllegalStateException.
Adapt live CameraX ImageProxy input without host pixel copying, tracking or decoder orchestration.
Inputs for MatrixScanAnalyzer(session: MatrixScanSession, listener: MatrixScanCameraListener): ImageAnalysis.Analyzer, AutoCloseable
Input
Type
Required
Meaning
session
MatrixScanSession
Yes
Borrowed authorized native session; analyzer never closes it.
listener
MatrixScanCameraListener
Yes
Worker callbacks onResult(MatrixScanCameraResult) and onError(MatrixScanCameraError). Keep callbacks short; callback exceptions propagate after release.
Result
One typed snapshot per processed frame, no retained camera buffer. Every delivered ImageProxy is closed.
Lifecycle
YUV_420_888, KEEP_ONLY_LATEST, single worker. Concurrent/closed live calls are released without decoding. close stops new work; admitted work still delivers its worker callback/evidence. Host stops/unbinds, closes session on worker, then shuts down executor. Discard stale UI painting only.
Trust boundary
No logging or media persistence. Borrowed session keeps license checks; analyzer adds no Scandit dependency.
Failure behavior
INVALID_IMAGE, ENTITLEMENT_DENIED and PROCESSING_FAILED carry no raw exception/payload.
Native result statuses remain available in frame.result; no decode is a normal empty result.
Map only current stable native quads to PreviewView pixels through CameraX CoordinateTransform.
Inputs for MatrixScanCameraResult.mapVisibleTracks(previewTransform: OutputTransform): List<MatrixScanOverlay>
Input
Type
Required
Meaning
previewTransform
androidx.camera.view.transform.OutputTransform
Yes
Non-null PreviewView transform from the same ViewPort and camera binding as this frame.
Result
MatrixScanOverlay(track: MatrixTrack, quad: List<MatrixPoint>): original native track and four mapped preview-pixel points; original track.quad unchanged.
Lifecycle
Map/render on UI after preview layout. Discard previous-binding callbacks; do not rotate or crop mapped geometry twice. Raw frame timestamp is frame.timestampNs.
Trust boundary
Transforms do not infer payload, identity, target matching or count.
Failure behavior
Invalid/non-invertible/non-finite transform fails; never substitute guessed rectangles.
Wrong camera binding/ViewPort is caller misuse; clear overlays and rebind rather than painting stale geometry.
Licensed native MatrixScan usage reporting
PRXV-0132-S04: opt-in, content-free native acceptance/processing deltas to the existing tenant-authenticated ingestion API. Metrics schema: contracts/json/matrix-scan-usage.schema.json. Live staging delivery and analytics projections remain validation/downstream gates.
Attach SDK-owned usage collection to subsequently created MatrixScan sessions, with independent bounded reporting work.
Inputs for VisionScanSdk.startMatrixTelemetry(options: MatrixTelemetryOptions, tokenProvider: () -> String): MatrixScanTelemetry
Input
Type
Required
Meaning
options
MatrixTelemetryOptions
Yes
Trusted HTTPS control-plane origin, actual SDK version, bounded interval/capacity and optional encrypted host storage.
tokenProvider
() -> String
Yes
Worker-only provider of the complete workspace device SDK key used for initialization; the existing enrolled bearer-token path is also supported. Never supply the signed license JWS.
Result
Lifecycle handle with typed status, queued/dropped/rejected counters, flushAsync, close, isStopped and awaitStopped.
Lifecycle
Verified UUID-device license first; reporting before native session creation. Close on logout/switch, then awaitStopped on a cleanup worker before reusing storage or restarting. One reporter/file writer.
Trust boundary
No tenant authority in request body; server checks claims and device licensing. No barcode value, image, quad, track ID, key/token or arbitrary diagnostic text. Opt-in, no redirects; five fixed mode buckets. Telemetry is not a billing or receiving authority.
Failure behavior
Invalid origin/version/bounds or missing verified UUID-device license rejects start.
Transport failure retains stable IDs; only matching per-event outcomes retire events.
Queue saturation delays new counters in fixed buckets; shutdown overflow and terminal rejections expose statistics losses, never receipt loss.
Corrupt/foreign encrypted spool stops delivery without overwriting it.