to top
Datalogic APIs
public class

BarcodeManager

extends Object
implements PropertyEditor
java.lang.Object
   ↳ com.datalogic.decode.BarcodeManager

Class Overview

BarcodeManager gives developers access to decoder related methods of the device.

To decode bar codes with this class, use the following steps:

  1. Obtain an instance of BarcodeManager with BarcodeManager();
  2. Register the listeners needed in your application from the available ones: StartListener, ReadListener, StopListener and TimeoutListener;
  3. To begin a decode session, call startDecode(). Your registered StartListener/ReadListener/TimeoutListener will be called when a successful decode occurs or if the configured timeout expires, etc;
  4. Call stopDecode() to end the decode session;
  5. Call release() to release all registered StartListener/ReadListener/TimeoutListener/StopListener.

Configuration persistance: All the configuration changes done using the BarcodeManager are natively not persistent to the device reboot, they are kept only in the current device session. If you want to persist your changes in flash and keep them across a system reboot the only existing way is to call explicitally commitProperties(). Beware that the decoding system configuration is restored from flash every time the decoding service restart and so any configuration not stored persistently could be lost if the service is killed (and consequently restarted) by the Android OS. It is a rare event that could happens for many reasons (low resources, execution exception, not responding service, etc...), the decoding system is usually restored but any configuration not stored persistently could be lost.

Summary

Constants
String ACTION_START_DECODE Barcode start decode intent action.
String ACTION_STOP_DECODE Barcode stop decode intent action.
Fields
public static final int KEYCODE_BARCODE Android keycode representing the scanning functionality, in accordance with android.view.KeyEvent.
Public Constructors
BarcodeManager()
This is the constructor of BarcodeManager.
Public Methods
int addDeinitListener(DeinitListener listener)
Registers a DeinitListener to be notified when a event of Scanner de-initiliazion is triggered.
int addFrameCaptureListener(FrameCaptureListener listener)
Registers a FrameCaptureListener to be notified when a frame capture event is triggered.
int addFrameSaveListener(FrameSaveListener listener)
Registers a FrameSaveListener to be notified when a frame save event is triggered.
int addInitListener(InitListener listener)
Registers a InitListener to be notified when a event of completed Scanner initialization is triggered.
int addPresentationStateListener(PresentationStateListener listener)
Registers a PresentationStateListener to be notified when a presentation mode state change event is triggered.
int addReadListener(ReadListener listener)
Registers a ReadListener to be notified when a read event is triggered.
int addStartListener(StartListener listener)
Registers a StartListener to be notified when a scan started event is triggered.
int addStopListener(StopListener listener)
Registers a StopListener to be notified when a scan stopped event is triggered.
int addTimeoutListener(TimeoutListener listener)
Registers a TimeoutListener to be notified when a scan timeout event is triggered.
int commitProperties()
Saves the configuration.
int enableAllSymbologies(boolean enable)
Enables or disables all supported symbologies.
int enableSymbology(Symbology barcodeType, boolean enable)
Enables or disables a barcode symbology type.
InputDevice getCurrentInputDevice()
Gets the input device in use.
List<CustomOCR> getCustomOcrItems()
Returns the list of custom OCR configurations found in the device.
int getPropertyAvailability(int[] id_buffer, boolean[] availability_buffer)
Retrieves the availability, the support, for the passed programming parameters.
int getPropertyInts(int[] id_buffer, int[] value_buffer)
Gets one or more label programming parameters of type Integer.
int getPropertyRanges(int[] id_buffer, int[][] property_ranges)
Gets one or more property ranges for the passed programming parameters.
int getPropertyStrings(int[] id_buffer, String[] value_buffer)
Gets one or more label programming parameters of type String.
List<InputDevice> getSupportedInputDevices()
Gets the list of supported input devices.
boolean isInitialized()
Checks if the Scanner Service is correctly initialized.
boolean isSymbologyEnabled(Symbology barcodeType)
Returns current enable setting for a particular barcode symbology.
boolean isSymbologySupported(Symbology barcodeType)
Return true if the device's decoder is able to read a particular barcode symbology.
int pressTrigger()
Call this method to simulate a trigger button pressure.
int release()
Removes and clears all the registered listeners, in case some application did not call removal methods.
int releaseTrigger()
Call this method to simulate a release of a the trigger button.
int removeDeinitListener(DeinitListener listener)
Unregisters a DeinitListener associated with the decoder.
int removeFrameCaptureListener(FrameCaptureListener listener)
Unregisters a FrameCaptureListener associated with the decoder.
int removeFrameSaveListener(FrameSaveListener listener)
Unregisters a FrameSaveListener associated with the decoder.
int removeInitListener(InitListener listener)
Unregisters a InitListener associated with the decoder.
int removePresentationStateListener(PresentationStateListener listener)
Unregisters a PresentationStateListener associated with the decoder.
int removeReadListener(ReadListener listener)
Unregisters a ReadListener associated with the decoder.
int removeStartListener(StartListener listener)
Unregisters a StartListener associated with the decoder.
int removeStopListener(StopListener listener)
Unregisters a StopListener associated with the decoder.
int removeTimeoutListener(TimeoutListener listener)
Unregisters a TimeoutListener associated with the decoder.
void setCurrentInputDevice(InputDevice currentInputDevice)
Sets the input device in use.
int setDefaults()
Set factory defaults for all barcode symbology types.
int setPropertyInts(int[] id_buffer, int[] value_buffer)
Sets one or more label programming parameters of type Integer.
int setPropertyStrings(int[] id_buffer, String[] value_buffer)
Sets one or more label programming parameters of type String.
int startDecode(int timeout)
Call this method to start decoding.
int startDecode()
Call this method to start decoding.
int stopDecode()
This stops any data acquisition currently in progress.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.datalogic.device.configuration.PropertyEditor
From interface com.datalogic.device.configuration.PropertyGetter

Constants

public static final String ACTION_START_DECODE

Added in revision 1

Barcode start decode intent action. It is possible to start a capture session in order to scan a barcode from an application, sending a specific broadcast intent.

Example:
public int startDecodingIntent() {
  Intent myintent = new Intent();
  myintent.setAction(ACTION_START_DECODE);
}
Otherwise application can associate this intent to a physical key code through the KeyboardManager mapIntent method.

Constant Value: "com.datalogic.decode.action.START_DECODE"

public static final String ACTION_STOP_DECODE

Added in revision 1

Barcode stop decode intent action. When an application sends this broadcast intent, the system stops scanning.

Example:
public int stopDecodingIntent() {
  Intent myintent = new Intent();
  myintent.setAction(ACTION_STOP_DECODE);
}

Constant Value: "com.datalogic.decode.action.STOP_DECODE"

Fields

public static final int KEYCODE_BARCODE

Added in revision 1

Android keycode representing the scanning functionality, in accordance with android.view.KeyEvent.

It is possible to associate a device generic button to the scanning functionality through the mapping mechanism and the VScanEntry, this means a specific scan code can be mapped to the desired Android keycode.

Public Constructors

public BarcodeManager ()

Added in revision 1

This is the constructor of BarcodeManager.

Throws
DecodeException in case of error.

Public Methods

public int addDeinitListener (DeinitListener listener)

Added in revision 14

Registers a DeinitListener to be notified when a event of Scanner de-initiliazion is triggered. Call removeDeinitListener(DeinitListener) before the application closes to properly shut down the listener.

Parameters
listener The DeinitListener that will be called when a decoder's de-init event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addFrameCaptureListener (FrameCaptureListener listener)

Added in revision 22

Registers a FrameCaptureListener to be notified when a frame capture event is triggered. Call removeFrameCaptureListener(FrameCaptureListener) before the application closes to properly shut down the listener.

Parameters
listener The FrameCaptureListener that will be called when a decoder's read event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addFrameSaveListener (FrameSaveListener listener)

Added in revision 22

Registers a FrameSaveListener to be notified when a frame save event is triggered. Call removeFrameSaveListener(FrameSaveListener) before the application closes to properly shut down the listener.

Parameters
listener The FrameSaveListener that will be called when a decoder's read event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addInitListener (InitListener listener)

Added in revision 14

Registers a InitListener to be notified when a event of completed Scanner initialization is triggered. Call removeInitListener(InitListener) before the application closes to properly shut down the listener.

Parameters
listener The InitListener that will be called when a decoder's init event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addPresentationStateListener (PresentationStateListener listener)

Added in revision 26

Registers a PresentationStateListener to be notified when a presentation mode state change event is triggered. Call removePresentationStateListener(PresentationStateListener) before the application closes to properly shut down the listener.

Parameters
listener The PresentationStateListener that will be called when a presentation mode state change event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addReadListener (ReadListener listener)

Added in revision 1

Registers a ReadListener to be notified when a read event is triggered. Call removeReadListener(ReadListener) before the application closes to properly shut down the listener.

Parameters
listener The ReadListener that will be called when a decoder's read event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addStartListener (StartListener listener)

Added in revision 1

Registers a StartListener to be notified when a scan started event is triggered. Call removeStartListener(StartListener) before the application closes to properly shut down the listener.

Parameters
listener The StartListener that will be called when a decoder's started scan event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addStopListener (StopListener listener)

Added in revision 1

Registers a StopListener to be notified when a scan stopped event is triggered. Call removeStopListener(StopListener) before the application closes to properly shut down the listener.

Parameters
listener The StopListener that will be called when a decoder's stopped scan event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int addTimeoutListener (TimeoutListener listener)

Added in revision 1

Registers a TimeoutListener to be notified when a scan timeout event is triggered. Call removeTimeoutListener(TimeoutListener) before the application closes to properly shut down the listener.

Parameters
listener The TimeoutListener that will be called when a decoder's scan timeout event is fired.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int commitProperties ()

Added in revision 1

Saves the configuration. The configuration is saved in a persistent way across system reboot. See persistance note.

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int enableAllSymbologies (boolean enable)

Added in revision 1

Enables or disables all supported symbologies.
Note:
when the decoding configuration changes due a call to this method, it is not saved in a persistent way across system reboot. See persistance note.

Example:
public int enableAll() {
  decoder.enableAllSymbologies(true);
}

Parameters
enable boolean specifies whether or not the symbologies will be enabled. If false, the symbologies are disabled, otherwise they are enabled.
Returns
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int enableSymbology (Symbology barcodeType, boolean enable)

Added in revision 1

Enables or disables a barcode symbology type.
Note:
when the decoding configuration changes due a call to this method, it is not saved in a persistent way across system reboot. See persistance note.

Example:
public int enableCode39(BarcodeManager decoder) {
  decoder.enableSymbology(Symbology.CODE39, true);
}

Parameters
barcodeType Indicates the type of data whose enable setting is to be altered. (one of the barcode type in the Symbology class).
enable boolean specifies whether or not the data type will be enabled. If false, the data type is disabled, otherwise it is enabled.
Returns
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public InputDevice getCurrentInputDevice ()

Added in revision 33

Gets the input device in use.

Returns
  • The current input device.

public List<CustomOCR> getCustomOcrItems ()

Added in revision 34

Returns the list of custom OCR configurations found in the device.

Returns
  • A list of all custom OCR configurations available. The list is empty if there is no cusotm OCR configuration.

public int getPropertyAvailability (int[] id_buffer, boolean[] availability_buffer)

Added in revision 4

Retrieves the availability, the support, for the passed programming parameters.

Parameters
id_buffer The int[] of identifiers for parameters to look for.
availability_buffer The boolean[] of the passed IDs' availability, that will be filled in.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int getPropertyInts (int[] id_buffer, int[] value_buffer)

Added in revision 1

Gets one or more label programming parameters of type Integer.

Parameters
id_buffer The int[] of identifiers for parameters to get.
value_buffer The int[] of values associated to the passed IDs to get.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int getPropertyRanges (int[] id_buffer, int[][] property_ranges)

Added in revision 4

Gets one or more property ranges for the passed programming parameters.

Parameters
id_buffer The int[] of identifiers for parameters to look for.
property_ranges The int[][2] array of ranges associated to the passed IDs, that will be filled in. Each element will be filled with the range of the admissible values described by min and max value.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int getPropertyStrings (int[] id_buffer, String[] value_buffer)

Added in revision 1

Gets one or more label programming parameters of type String.

Parameters
id_buffer The int[] of identifiers for parameters to get.
value_buffer The String[] of values associated to the passed IDs to get.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public List<InputDevice> getSupportedInputDevices ()

Added in revision 33

Gets the list of supported input devices.

Returns
  • The list of input devices available.

public boolean isInitialized ()

Added in revision 14

Checks if the Scanner Service is correctly initialized.

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public boolean isSymbologyEnabled (Symbology barcodeType)

Added in revision 1

Returns current enable setting for a particular barcode symbology.

Example:
public boolean isCode39Enabled(BarcodeManager decoder) {
  return decoder.isSymbologyEnabled(Symbology.CODE39);
}

Parameters
barcodeType This gets the current enable setting for a particular data type. (one of the barcode typein the Symbology class).
Returns
  • boolean False is returned if the particular data type is disabled, and true is returned otherwise.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public boolean isSymbologySupported (Symbology barcodeType)

Added in revision 1

Return true if the device's decoder is able to read a particular barcode symbology.

Example:
public boolean isQRSupported(BarcodeManager decoder) {
  return decoder.isSymbologySupported(Symbology.QRCODE);
}

Parameters
barcodeType Barcode type is one of the Symbology.
Returns
  • boolean False is returned if the decoder is not able to read the particular barcode type, and true is returned otherwise.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int pressTrigger ()

Added in revision 1

Call this method to simulate a trigger button pressure.
The method does not always start immediately a capture, instead it behaves like pressing scan button.

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int release ()

Added in revision 1

Removes and clears all the registered listeners, in case some application did not call removal methods.

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int releaseTrigger ()

Added in revision 1

Call this method to simulate a release of a the trigger button.
The method does not always stop immediately a capture, instead it behaves like releasing scan button.

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeDeinitListener (DeinitListener listener)

Added in revision 14

Unregisters a DeinitListener associated with the decoder.

Parameters
listener The DeinitListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeFrameCaptureListener (FrameCaptureListener listener)

Added in revision 22

Unregisters a FrameCaptureListener associated with the decoder.

Parameters
listener The FrameCaptureListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeFrameSaveListener (FrameSaveListener listener)

Added in revision 22

Unregisters a FrameSaveListener associated with the decoder.

Parameters
listener The FrameSaveListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeInitListener (InitListener listener)

Added in revision 14

Unregisters a InitListener associated with the decoder.

Parameters
listener The InitListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removePresentationStateListener (PresentationStateListener listener)

Added in revision 26

Unregisters a PresentationStateListener associated with the decoder.

Parameters
listener The PresentationStateListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeReadListener (ReadListener listener)

Added in revision 1

Unregisters a ReadListener associated with the decoder.

Parameters
listener The ReadListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeStartListener (StartListener listener)

Added in revision 1

Unregisters a StartListener associated with the decoder.

Parameters
listener The StartListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeStopListener (StopListener listener)

Added in revision 1

Unregisters a StopListener associated with the decoder.

Parameters
listener The StopListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int removeTimeoutListener (TimeoutListener listener)

Added in revision 1

Unregisters a TimeoutListener associated with the decoder.

Parameters
listener The TimeoutListener that will be no more notified.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public void setCurrentInputDevice (InputDevice currentInputDevice)

Added in revision 33

Sets the input device in use.

Parameters
currentInputDevice The input device to set.

public int setDefaults ()

Added in revision 1

Set factory defaults for all barcode symbology types.
Note:
when the decoding configuration changes due a call to this method, it is not saved in a persistent way across system reboot. See persistance note.

Example:
public int setAllDefaults(BarcodeManager decoder) {
  decoder.setDefaults();
}

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setPropertyInts (int[] id_buffer, int[] value_buffer)

Added in revision 1

Sets one or more label programming parameters of type Integer. The change is not persistent across system reboot. See persistance note.

Parameters
id_buffer The int[] of identifiers for parameters to set.
value_buffer The int[] of values associated to the passed IDs to set.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int setPropertyStrings (int[] id_buffer, String[] value_buffer)

Added in revision 1

Sets one or more label programming parameters of type String. The change is not persistent across system reboot. See persistance note.

Parameters
id_buffer The int[] identifiers for parameters to set.
value_buffer The String[] of values associated to the passed IDs to set.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the ConfigException error constants.
Throws
ConfigException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int startDecode (int timeout)

Added in revision 1

Call this method to start decoding.
If the trigger is already active, the present timeout is reset to the new value and the count starts again.

Example:
public int startDecodingForFiveSeconds(BarcodeManager decoder) {
  decoder.startDecode(5000);
}

Parameters
timeout int representing the amount of time, in milliseconds, to continue the attempt to acquire data. If data has not been obtained after this time period, then the decoder is deactivated.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int startDecode ()

Added in revision 1

Call this method to start decoding.
Default timeout or the one set through the SDK will be applied.

Example:
public int startDecoding(BarcodeManager decoder) {
  decoder.startDecode();
}

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int stopDecode ()

Added in revision 1

This stops any data acquisition currently in progress.

Example:
public int abortDecoding(BarcodeManager decoder) {
  decoder.stopDecode();
}

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DecodeException error constants.
Throws
DecodeException in case of error, when exceptions are enabled through the ErrorManager singleton.