Spark Capture Listener#

Defined in package com.scandit.datacapture.barcode.spark.capture

Note

The Spark Capture API is still in beta and may change in future versions of the Scandit Data Capture SDK.

SparkCaptureListener#
interface SparkCaptureListener

Added in version 6.11.0

Listener interface for traditional spark capture.

onObservationStarted(sparkCapture)#
void onObservationStarted(@NonNull SparkCapture sparkCapture)

Added in version 6.11.0

Called when the listener starts observing the spark capture instance.

onObservationStopped(sparkCapture)#
void onObservationStopped(@NonNull SparkCapture sparkCapture)

Added in version 6.11.0

Called when the listener stops observing the spark capture instance.

onBarcodeScanned(sparkCapture, session, frameData)#
void onBarcodeScanned(@NonNull SparkCapture sparkCapture,
        @NonNull SparkCaptureSession session,
        @NonNull FrameData frameData)

Added in version 6.11.0

Invoked whenever a code has been scanned. The newly scanned codes can be retrieved from SparkCaptureSession.newlyRecognizedBarcodes.

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first. After receiving this callback, you will typically want to start processing the scanned barcodes. Keep in mind however, that any further recognition is blocked until this method completes. Therefore, if you need to perform a time-consuming operation, like querying a database or opening an URL encoded in the barcode data, consider switching to another thread.

Sometimes, after receiving this callback, you may want to pause scanning or to stop scanning completely.

  • To pause scanning, but keep the camera (frame source) running, just set the spark capture’s enabled property to false.

  • To stop scanning, you will need to both disable the capture mode and stop the frame source. While it’s possible to only stop the camera and keep the capture mode enabled, this may lead to additional scan events being delivered, which is typically not desired. The following lines of code show how to disable the capture mode and stop the frame source as well:

onSessionUpdated(sparkCapture, session, frameData)#
void onSessionUpdated(@NonNull SparkCapture sparkCapture,
        @NonNull SparkCaptureSession session,
        @NonNull FrameData frameData)

Added in version 6.11.0

Invoked after a frame has been processed by spark capture and the session has been updated. In contrast to onBarcodeScanned(), this method is invoked, regardless whether a code was scanned or not. If codes were recognized in this frame, this method is invoked after onBarcodeScanned().

This method is invoked from a recognition internal thread. To perform UI work, you must dispatch to the main thread first. Further recognition is blocked until this method completes. It is thus recommended to do as little work as possible in this method.