android.device
Class ScanManager

java.lang.Object
  extended by android.device.ScanManager

public class ScanManager
extends java.lang.Object

The ScanManager class provides developers access to barcode reader related in the device

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

  1. Obtain an instance of BarCodeReader with ScanManager scan = new ScanManager().
  2. Call openScanner() to power on the bar code reader.
  3. If necessary, get the current settings with getParameterInts(int[]).
  4. If necessary, modify the returned PropertyID object value and call setParameterInts(int[], int[]).
    Example:
    public void getOutputMode() {
       int[] index = new int[]{ PropertyID.WEDGE_KEYBOARD_ENABLE};
       int[] value = scan.getParameterInts(index);
    }
    public void setOutputMode() {
       int[] index = new int[]{ PropertyID.WEDGE_KEYBOARD_ENABLE, PropertyID.WEDGE_KEYBOARD_TYPE, PropertyID.GOOD_READ_BEEP_ENABLE};
       int[] value = new int[]{1, 1, 1};
       int ret = scan.setParameterInts(index, value);
    }
  5. If necessary, set the current broadcast intent settings.

    Intent mode allows the captured data to be sent as an implicit Intent. Application interested in the scan data should register default action as android.intent.ACTION_DECODE_DATA broadcast listerner.

    public void updatetDecodingIntent() {
       int[] index = new int[]{ PropertyID.WEDGE_INTENT_ACTION_NAME, PropertyID.WEDGE_INTENT_DATA_STRING_TAG};
       String[] value = scan.getParameterString(index);
       value[0] = "android.scan.data";
       value[1] = "dataString";
       boolean ret = scan.setParameterInts(index, value);
    }
  6. To begin a decode session, call startDecode(). if the configured PropertyID.WEDGE_KEYBOARD_ENABLE is 0.Your registered broadcast receiver will be called when a successful decode occurs.
  7. Call stopDecode() to end the decode session.
  8. Call closeScanner() to power off the bar code reader.


Field Summary
static java.lang.String ACTION_DECODE
           
static java.lang.String BARCODE_LENGTH_TAG
          String contains the label length of the bar code
static java.lang.String BARCODE_STRING_TAG
           
static java.lang.String BARCODE_TYPE_TAG
          String contains the label type of the bar code
static java.lang.String DECODE_DATA_TAG
          String contains the output data as a byte array.
 
Constructor Summary
ScanManager()
           
 
Method Summary
 boolean closeScanner()
          Turn off the power for the bar code reader.
 void enableAllSymbologies(boolean enable)
          Enables or disables all supported symbologies.
 void enableSymbology(Symbology barcodeType, boolean enable)
          Enables or disables a barcode symbology type.
 int getOutputMode()
          get current the scan result output mode
 int[] getParameterInts(int[] id_buffer)
          Gets one or more programming parameters of type Integer from the scan engine
 java.lang.String[] getParameterString(int[] id_buffer)
          Gets label programming parameters of type String at the specified indexs.
 boolean getScannerState()
          get the scanner power states
 boolean getTriggerLockState()
          get the scan trigger status
 Triggering getTriggerMode()
          Returns current configure triggering decode mode.
 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.
 boolean lockTrigger()
          Set the scan trigger inactive (disable the scan button)
 boolean openScanner()
          Turn on the power for the bar code reader.
 boolean resetScannerParameters()
          Set factory defaults for all barcode symbology types.
 int setParameterInts(int[] id_buffer, int[] value_buffer)
          Sets one or more label programming parameters of type Int
 boolean setParameterString(int[] id_buffer, java.lang.String[] value_buffer)
          Set the scanner parameter of type String at the specified indexes.
 void setTriggerMode(Triggering mode)
          This method set specifies which mode to control decode.
 boolean startDecode()
          Call this method to start decoding.
 boolean stopDecode()
          This stops any data acquisition currently in progress.
 boolean switchOutputMode(int mode)
          Use this function to set the output mode of the barcode reader (either send output to text box or as Android intent).
 boolean unlockTrigger()
          Set the scan trigger active (enable the scan button)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_DECODE

public static final java.lang.String ACTION_DECODE
See Also:
Constant Field Values

BARCODE_STRING_TAG

public static final java.lang.String BARCODE_STRING_TAG
See Also:
Constant Field Values

BARCODE_TYPE_TAG

public static final java.lang.String BARCODE_TYPE_TAG
String contains the label type of the bar code

See Also:
Constant Field Values

BARCODE_LENGTH_TAG

public static final java.lang.String BARCODE_LENGTH_TAG
String contains the label length of the bar code

See Also:
Constant Field Values

DECODE_DATA_TAG

public static final java.lang.String DECODE_DATA_TAG
String contains the output data as a byte array. In the case of concatenated bar codes, the decode data is concatenated and sent out as a single array

See Also:
Constant Field Values
Constructor Detail

ScanManager

public ScanManager()
Method Detail

switchOutputMode

public boolean switchOutputMode(int mode)

Use this function to set the output mode of the barcode reader (either send output to text box or as Android intent).

TextBox Mode allows the captured data to be sent to the text box in focus.

Intent mode allows the captured data to be sent as an implicit Intent. Application interested in the scan data should register an action as android.intent.ACTION_DECODE_DATA broadcast listerner.

In the onReceive(Context context, Intent arg1) method, get the information as follow:
byte[] barcode=arg1.getByteArrayExtra("barcode");
int barcodelen=arg1.getIntExtra("length",0);
byte type=arg1.getByteExtra("barcodeType",(byte)0);

The information are bar code data, length of bar code data, and bar code type (symbology).

Parameters:
mode - Set to 0 if barcode output is to be sent as intent, barcode output is to be sent to the text box in focus
Returns:
Returns true if successful. Returns false if failed.

getOutputMode

public int getOutputMode()
get current the scan result output mode

Returns:
Returns zero if the barcode is sent as intent. Returns 1 if barcode is sent to the text box in focus

openScanner

public boolean openScanner()
Turn on the power for the bar code reader.

Returns:
false if failed. true if success,

closeScanner

public boolean closeScanner()
Turn off the power for the bar code reader.

Returns:
false if failed. true if success,

getScannerState

public boolean getScannerState()
get the scanner power states

Returns:
true if the scanner power on.

stopDecode

public boolean stopDecode()
This stops any data acquisition currently in progress.

Returns:
true if stop successed.

startDecode

public boolean startDecode()
Call this method to start decoding.

Returns:
true if the sanner and the trigger is already active

lockTrigger

public boolean lockTrigger()
Set the scan trigger inactive (disable the scan button)

Returns:
Returns true if successful. Returns false if failed.

unlockTrigger

public boolean unlockTrigger()
Set the scan trigger active (enable the scan button)

Returns:
Returns true if successful. Returns false if failed.

getTriggerLockState

public boolean getTriggerLockState()
get the scan trigger status

Returns:
true if the scan trigger is already active

resetScannerParameters

public boolean resetScannerParameters()
Set factory defaults for all barcode symbology types.

Returns:
true if succeed

setTriggerMode

public void setTriggerMode(Triggering mode)
This method set specifies which mode to control decode.

Parameters:
Specifies - which mode. a trigger will activate the scan engine and start decoding. It will be deactivated when a valid code is found, or when time out is reached. Pulse - a trigger will activate the scan engine, and start decoding. It will be deactivated when a valid code is found, or when the trigger is released, or when the time out is reached. Continuous - Scan engine is always on and always decoding. Triggering

getTriggerMode

public Triggering getTriggerMode()
Returns current configure triggering decode mode.

Returns:
mode info Triggering

setParameterInts

public int setParameterInts(int[] id_buffer,
                            int[] value_buffer)
Sets one or more label programming parameters of type Int

Parameters:
id_buffer - The indexes to the parameters to be set. PropertyID
value_buffer - the values to be used.
Returns:

getParameterInts

public int[] getParameterInts(int[] id_buffer)
Gets one or more programming parameters of type Integer from the scan engine

Parameters:
id_buffer - The indexes to the programming parameteres. PropertyID
Returns:
int arrary of the parameters.

setParameterString

public boolean setParameterString(int[] id_buffer,
                                  java.lang.String[] value_buffer)
Set the scanner parameter of type String at the specified indexes.

Parameters:
id_buffer - to the parameter that is to be set PropertyID
value_buffer - the string used to set the parameter
Returns:
False is returned if the index or value is error, and true is returned otherwise.

getParameterString

public java.lang.String[] getParameterString(int[] id_buffer)
Gets label programming parameters of type String at the specified indexs.

Parameters:
id_buffer - The indexes to the programming parameteres. PropertyID
Returns:
string arrary of the parameters.

isSymbologySupported

public boolean isSymbologySupported(Symbology barcodeType)
Return true if the device's decoder is able to read a particular barcode symbology.

Parameters:
barcodeType - Barcode type is one of the Symbology.
Returns:
False is returned if the decoder is not able to read the particular barcode type, and true is returned otherwise.
Example:
public boolean isQRSupported(ScanManager decoder) {
  return decoder.isSymbologySupported(Symbology.QRCODE);
}

isSymbologyEnabled

public boolean isSymbologyEnabled(Symbology barcodeType)
Returns current enable setting for a particular barcode symbology.

Parameters:
barcodeType - This gets the current enable setting for a particular data type. (one of the barcode typein the Symbology class).
Returns:
False is returned if the particular data type is disabled, and true is returned otherwise.
Example:
public boolean isCode128Enabled(ScanManager decoder) {
  return decoder.isSymbologyEnabled(Symbology.CODE128);
}

enableAllSymbologies

public void enableAllSymbologies(boolean enable)
Enables or disables all supported symbologies.

Parameters:
enable - Specifies whether or not the symbologies will be enabled. If false, the symbologies are disabled, otherwise they are enabled.
Note:
when the decoding configuration changes due a call to this method, the Scanner engine must be in the power on state.

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

enableSymbology

public void enableSymbology(Symbology barcodeType,
                            boolean enable)
Enables or disables a barcode symbology type.

Parameters:
barcodeType - Indicates the type of data whose enable setting is to be altered. (one of the barcode type in the Symbology class).
enable - Specifies whether or not the data type will be enabled. If false, the data type is disabled, otherwise it is enabled.
Note:
when the decoding configuration changes due a call to this method,the Scanner engine must be in the power on state.

Example:
public void enableCode128(ScanManager decoder) {
  decoder.enableSymbology(Symbology.CODE128, true);
}