public class Scanner
extends java.lang.Object
Scanner access is only available when running on a native TotalCross VM; it
is not supported when running on Java. It is, though, emulated on Java:
a popup dialog will ask you for a barcode symbol which will be returned every time
the getData
method is called.
Since there is only one scanner per device, the scanner class is static. Activating the scanner causes the physical scanner to be powered, and enables the trigger. Deactivating the scanner removes the power from the scanner and prevents scans from taking place. The scanner should always be deactivated at the end of processing to prevent excessive battery drain.
When the scanner is activated, scan events will appear in the MainWindow's onEvent method. The scan events will contain a string describing either the item scanned or a battery error. Deactivating the scanner prevents scan events from being delivered.
Since barcodes can have many formats, this class includes a method to register the barcode types with the scanner. These types must each be individually set as parameters to the scanner. After all the parameter types have been set, the commitBarcodeParams method must be called to register the parameters with the scanner. Once this is done the scanner is able to decode the specified barcode types.
A typical processing sequence is given below:
if (!Scanner.activate() || !Scanner.setBarcodeParam(Intermec.AZTEC, true) || !Scanner.commitBarcodeParams()) return; ... if (!Scanner.deactivate()) return;Note: to generate an installation for the SYMBOL MC32, you must deploy using -WINCE (creates cab without compression), and not -WINMO (creates cab with compression).
Modifier and Type | Field and Description |
---|---|
static boolean |
isActive |
static Control |
listener
Set this listener to send all Scanner events to its onEvent method.
|
static java.lang.String |
scanManagerVersion
The scanner version.
|
Constructor and Description |
---|
Scanner() |
Modifier and Type | Method and Description |
---|---|
protected static void |
_onEvent(int type)
Dispatch the event to the current listener (associated through the
listener public member. |
static boolean |
activate()
Activate the scanner.
|
static boolean |
commitBarcodeParams()
Commit the barcode parameters to the scanner.
|
static boolean |
deactivate()
Deactivate the scanner.
|
static java.lang.String |
getData()
Get the decoded string of what has been scanned.
|
static java.lang.String |
getScanManagerVersion()
Get the scan manager version as an hexadecimal String.
|
static java.lang.String |
getScanPortDriverVersion()
Get the Scanner Port Driver version as an hexadecimal string.
|
static void |
proprietaryScanLoad(java.lang.Runnable scanLoad) |
static java.lang.String |
readBarcode(java.lang.String mode)
Reads a barcode using ZXing for Android.
|
static boolean |
setBarcodeLength(int barcodeType,
int lengthType,
int min,
int max)
Set the length of a barcode.
|
static boolean |
setBarcodeParam(int barcodeType,
boolean enable)
Set a scanner parameter defining whether a barcode format will be used
in scanning.
|
static boolean |
setParam(int type,
int barcodeType,
int value)
Set a parameter for the barcode.
|
static void |
setParam(java.lang.String what,
java.lang.String value)
Used in the Honeywell Android barcode scanners.
|
public static boolean isActive
public static java.lang.String scanManagerVersion
public static Control listener
public static void proprietaryScanLoad(java.lang.Runnable scanLoad)
public static boolean activate()
Note: On Android Intermec, you can't activate the scanner if it is off in the settings. Moreover, you should not set the scanner and virtual wedge settings off and then try to use the scanner. Even though your app won't crash or hang, the device might not behave properly. There is no way to check if the device settings are off in the settings or in the app.
public static boolean setBarcodeParam(int barcodeType, boolean enable)
barcodeType
- the type of barcode under considerationenable
- a flag to enable or disable decoding barcodes of this type.
Note: On Android Intermec, you CAN'T set enable a barcode type the scanner is not activate. In this case, this method will return false.
public static boolean setParam(int type, int barcodeType, int value)
With Datalogic scanners, the SECOND parameter is not used (always pass 0 to it); and don't forget to call the commitBarcodeParams method.
Values valid for SYMBOL scanners:
// triggering modes #define LEVEL 0x00 #define PULSE 0x02 #define HOST 0x08 // Linear code type security #define SECURITY_LEVEL0 0x00 #define SECURITY_LEVEL1 0x01 #define SECURITY_LEVEL2 0x02 #define SECURITY_LEVEL3 0x03 #define SECURITY_LEVEL4 0x04 // UPC/EAN Supplementals #define IGNORE_SUPPLEMENTALS 0x00 #define DECODE_SUPPLEMENTALS 0x01 #define AUTODISCRIMINATE_SUPPLEMENTALS 0x02 // Transmit Check Digit options #define DO_NOT_TRANSMIT_CHECK_DIGIT 0x00 #define TRANSMIT_CHECK_DIGIT 0x01 // Preamble options #define NO_PREAMBLE 0x00 #define SYSTEM_CHARACTER 0x01 #define SYSTEM_CHARACTER_COUNTRY_CODE 0x02 // CheckDigit verification options #define DISABLE_CHECK_DIGIT 0x00 #define USS_CHECK_DIGIT 0x01 #define OPCC_CHECK_DIGIT 0x02 // MSI Plessey checkdigit options #define ONE_CHECK_DIGIT 0x00 #define TWO_CHECK_DIGITS 0x01 // MSI Plessey check digit algorithms #define MOD10_MOD11 0x00 #define MOD10_MOD10 0x01 // Transmit Code ID Character options #define AIM_CODE_ID_CHARACTER 0x01 #define SYMBOL_CODE_ID_CHARACTER 0x02 // Scan data transmission formats #define DATA_AS_IS 0x00 #define DATA_SUFFIX1 0x01 #define DATA_SUFFIX2 0x02 #define DATA_SUFFIX1_SUFFIX2 0x03 #define PREFIX_DATA 0x04 #define PREFIX_DATA_SUFFIX1 0x05 #define PREFIX_DATA_SUFFIX2 0x06 #define PREFIX_DATA_SUFFIX1_SUFFIX2 0x07 // Scan angle options #define SCAN_ANGLE_WIDE 0xB6 #define SCAN_ANGLE_NARROW 0xB5
This method is ignored for Intermec scanners.
public static boolean commitBarcodeParams()
Not used on the Windows CE and Android platforms.
public static boolean setBarcodeLength(int barcodeType, int lengthType, int min, int max)
This method is ignored for Intermec scanners. The lengthType must be one of the following values:
barcodeType
- One of the BARxxxx constantslengthType
- 0 (variables length, min, and max are ignored), 1 (length = min), 2 (length = min || length = max), 3 (min <= length <= max). Careful: in Motorola Scanners, min and max must be used in inverted order due to a bug in the MOTOROLA API.min
- The minimum valuemax
- The maximum valuepublic static java.lang.String getData()
Note: On Android Intermec, you should first set some parameters before fetching data or else it might crash after 10 or 15 reads.
public static java.lang.String getScanManagerVersion()
public static java.lang.String getScanPortDriverVersion()
public static boolean deactivate()
protected static void _onEvent(int type)
listener
public member. Called from the native library.
If there are no assigned listeners, the event is sent to the top most window,
and the window is validated.public static java.lang.String readBarcode(java.lang.String mode)
public static void setParam(java.lang.String what, java.lang.String value)
Scanner.setParam(Honeywell.START_BATCH,"true"); ... set other parameters Scanner.setParam(Honeywell.END_BATCH,"true");Dont forget the start and end batch, otherwise it won't work! For boolean parameters, use "true" or "false". For integer parameters, use the integer passed as String.