4.3. API callbacks

Most enioka Scan actions use callbacks to communicate their result to your code. In the case of scanner-related callbacks, proxy classes exist to wrap callback implementations and ensure their methods are called on the UI thread.

This page regroups all callback interfaces from enioka Scan.

4.3.1. The ScannerCommandCallback interface and ScannerCommandCallbackProxy class

Callback used to inform of the result of scanner commands, usually optional.

onSuccess() void

Called when the command was completed, and if it received a positive answer (when applicable).

onFailure() void

Called when the command failed, either through or SDK error or negative answer (when applicable).

onTimeout() void

Called when the command’s expected answer did not arrive in time (usually only with BT scanners).

4.3.2. The ScannerConnectionHandler interface and ScannerConnectionHandlerProxy class

Callback used during the scanner search to retrieve created Scanner instances.

scannerConnectionProgress(String providerKey, String scannerKey, String message) void

A SDK-specific localized message signaling a change during the search for a scanner.

Parameters:
  • providerKey (String) – The identifier of the provider/SDK

  • scannerKey (String) – A unique identifier for the scanner being connected

  • message (String) – An SDK-specific message (localized)

scannerCreated(String providerKey, String scannerKey, Scanner s) void

Called when a scanner was found and created. Depending on ScannerSearchOptions.returnOnlyFirst may be called multiple times.

Parameters:
  • providerKey (String) – The identifier of the provider/SDK

  • scannerKey (String) – A unique identifier for the scanner being connected

  • s (Scanner) – The scanner instance

noScannerAvailable() void

Called when there is no scanner available on the device. endOfScannerSearch() is always called after this.

endOfScannerSearch() void

Called when the search for scanners in the different providers is over.

4.3.3. The ScannerDataCallback interface and ScannerDataCallbackProxy class

Callback used to handle the data read by the scanner.

onData(Scanner s, List<Barcode> data) void

Called whenever data is read by the scanner.

Parameters:
  • s (Scanner) – The scanner from which data was read

  • data (List<Barcode>) – The data read by the scanner

4.3.4. The ScannerInitCallback interface and ScannerInitCallbackProxy class

Callback handling scanner init events.

onConnectionSuccessful(Scanner s) void

Called whenever a scanner successfully connected.

Parameters:

s (Scanner) – The connected scanner.

onConnectionFailure(Scanner s) void

Called whenever a scanner could not connect.

Parameters:

s (Scanner) – The disconnected scanner.

4.3.5. The ScannerStatusCallback interface and ScannerStatusCallbackProxy class

enum Status

This enum represents the scanner’s lifecycle, as well as the current status of the scanner, scanner provider and scanner service’s search. Some elements may not be used depending on which scanner SDK is used.

WAITING:

The scanner provider is waiting for a connection.

CONNECTING:

The scanner is in the process of connecting.

RECONNECTING:

The scanner disconnected but is trying to reconnect.

CONNECTED:

The scanner has finished connecting.

INITIALIZING:

The scanner is in the process of initializing.

INITIALIZED:

The scanner has finished initializing.

READY:

The scanner is ready to scan and waiting to be used.

SCANNING:

The scanner is in the process of scanning.

PAUSED:

The scanner is connected, initialized and enabled but not ready to scan.

DISABLED:

The scanner is connected and initialized but has been disabled and cannot be used.

FAILURE:

The scanner is no longer available after a critical error occurred, usually during connection or initialization.

DISCONNECTED:

The scanner disconnected and can no longer be used.

UNKNOWN:

The scanner is in an unknown status.

SERVICE_PROVIDER_SEARCH_OVER:

ScannerService’s provider search is over.

SERVICE_SDK_SEARCH_OVER:

ScannerService’s SDK search is over.

SERVICE_SDK_SEARCH_NOCOMPATIBLE:

ScannerService’s SDK search found no scanner.

onStatusChanged(Scanner scanner, Status newStatus) void

Called whenever the scanner has changed status.

Parameters:
  • scanner (Scanner) – The updated scanner. May be null if the scanner has not yet been created.

  • newStatus (Status) – The new scanner status.

4.3.6. The ProviderDiscoveredCallback interface and ProviderDiscoveredCallbackProxy class

Callback used during provider discovery (before scanner search).

onDiscoveryDone() void

Called once all providers are discovered.

4.3.7. The ScannerProvider.ProviderCallback interface

Callback used by a scanner provider to inform the search process whether it is available and able to connect to a scanner.

onScannerCreated(String providerKey, String scannerKey, Scanner s) void

Called when the provider has finished creating a scanner.

Parameters:
  • providerKey (String) – The identifier of the provider/SDK

  • scannerKey (String) – A unique identifier for the scanner being connected

  • s (Scanner) – The scanner instance

connectionProgress(String providerKey, String scannerKey, String message) void

Send a localized status message to the end user.

Parameters:
  • providerKey (String) – The identifier of the provider/SDK

  • scannerKey (String) – A unique identifier for the scanner being connected

  • message (String) – The message (localized)

onProviderUnavailable(String providerKey) void

Called when the provider has determined it cannot run (is not available) on this device and should not be revived.

Parameters:

providerKey (String) – The identifier of the provider/SDK

onAllScannersCreated(String providerKey) void

Called if the provider can run, and all scanners have already been created.

Parameters:

providerKey (String) – The identifier of the provider/SDK

isAlreadyConnected(BluetoothDevice device) void

Called if a bluetooth device was already taken by a previous provider.

Parameters:

device (BluetoothDevice) – The busy bluetooth device

4.3.8. The BtSppScannerProvider.ManagementCallback interface

Callback used by bluetooth scanner providers to inform the master bluetooth provider that it cannot manage the device it was tested for.

canManage(Scanner libraryScanner) void

Called if the provider can manage the device.

Parameters:

libraryScanner (Scanner) – The corresponding Scanner instance.

cannotManage() void

Called if the provider can not manage the device.

4.3.9. The CameraBarcodeScanView.ResultHandler interface

Callback used by the camera reader when a barcode is read from the camera feed.

handleScanResult(String result, BarcodeType type) void
Parameters:
  • result (String) – The barcode data

  • type (BarcodeType) – The barcode symbology