BarcodeUtility

com.barcode

## Class BarcodeUtility

- java.lang.Object
- - com.barcode.BarcodeUtility

-     public class BarcodeUtility
      extends java.lang.Object

  条码操作类
  barcode operate class

  注意：
  Attention:
  1、使用前请确认您的机器已安装键盘助手v1.9.0 之后的版本。
  1. Confirm keyboardeumulator v1.9.0 has been installed before using.

  Author:
    zhoupin

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `BarcodeUtility.ModuleType`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE`
    `static java.lang.String` | `SCANNER_BARCODE_1D` 1D是否已经开启
    `static java.lang.String` | `SCANNER_BARCODE_2D` 2D是否已经开启
    `static java.lang.String` | `SCANNER_BARCODENOTREPEAT` 条码是否重复显示
    `static java.lang.String` | `SCANNER_BROADCAST_ACTION` 接收扫描数据的广播ACTION
    `static java.lang.String` | `SCANNER_BROADCAST_EXTRA` 接收扫描数据的广播的extra数据
    `static java.lang.String` | `SCANNER_CONTINUOUS` 是否是连续扫描 Whether enable continuous scan
    `static java.lang.String` | `SCANNER_CONTINUOUS_INTREVALTIME` 连续扫描时间间隔
    `static java.lang.String` | `SCANNER_CONTINUOUSMODE` 是否启用了连续扫描模式
    `static java.lang.String` | `SCANNER_CONTINUOUSTIMEOUT` 连续扫描超时时间 continuous scanning overtime duration
    `static java.lang.String` | `SCANNER_ENDINDEX` 后面去掉多少个字符
    `static java.lang.String` | `SCANNER_ENTER` 是否启用回车
    `static java.lang.String` | `SCANNER_FAILUREBROADCAST` 扫描失败是否发送广播 Send broadcast when scanning failure.
    `static java.lang.String` | `SCANNER_FAILURESOUND` 扫描失败是否播放声音 whether playing notification when scanning failure.
    `static java.lang.String` | `SCANNER_FILTERCHARS` 条码数据需要过滤的字符串
    `static java.lang.String` | `SCANNER_FORMAT_BARCODE` 条码格式 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030 Barcode format 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030
    `static java.lang.String` | `SCANNER_ILLUMINATIONPOWERLEVEL` 4710 扫描头亮度等级
    `static java.lang.String` | `SCANNER_KEYBORADHELPER_OPEN` 键盘助手总开关是否已经打开
    `static java.lang.String` | `SCANNER_OUTPUTMODE` 数据接收方式 0:键盘模拟 1:剪切板 2:系统广播 ouput mode 0: virtual key 1: clipboard 2: broadcast
    `static java.lang.String` | `SCANNER_PREFIX` 条码前缀 barcode prefix.
    `static java.lang.String` | `SCANNER_RELEASESCAN` 松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
    `static java.lang.String` | `SCANNER_SCANKEYCODE_1` 扫描按键值 scan key code.
    `static java.lang.String` | `SCANNER_SCANKEYCODE_3` 扫描按键值 scan key code.
    `static java.lang.String` | `SCANNER_SOUND` 扫描成功是否播放声音
    `static java.lang.String` | `SCANNER_STARTINDEX` 前面去掉多少个字符
    `static java.lang.String` | `SCANNER_SUFFIX` 条码后缀 barcode suffix.
    `static java.lang.String` | `SCANNER_TAB` 是否启用tab
    `static java.lang.String` | `SCANNER_TIMEOUT` 扫描超时 scanning time out.
    `static java.lang.String` | `SCANNER_VIBRATE` 是否启用震动 whether vibrating when scanning success

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close(Context context, BarcodeUtility.ModuleType modul)` 关闭指定功能 Switch off designated function
    `void` | `closeKeyboardHelper(Context context)` 关闭键盘助手功能总开关 Switch off main function switch of keyboardemulator
    `void` | `enableContinuousScan(Context context, boolean isContinuous)` 启用连续扫描 Enable continuous scan
    `void` | `enableEnter(Context context, boolean isEnter)` 是否启用回车 Whether enable Enter function
    `void` | `enablePlayFailureSound(Context context, boolean isFailureSound)` 扫描失败是否播放提示音 whether playing notification when scanning failure.
    `void` | `enablePlaySuccessSound(Context context, boolean isSuccessSound)` 是否播放成功的提示音 whether playing notification when scanning success.
    `void` | `enableTAB(Context context, boolean isTab)` 是否启用TAB Whether enable TAB function
    `void` | `enableVibrate(Context context, boolean isVibrate)` 扫描成功是否震动提示 whether vibrating when scanning success
    `void` | `filterCharacter(Context context, java.lang.String chars)` 过滤字符串 Filter charactor string
    `static BarcodeUtility` | `getInstance()` 获取条码操作实例 Acquire barcode operation Instance.
    `void` | `getKeyboardHelperParam(Context context)` 获取键盘助手状态值,通过action接收数据`ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE`.(备注：键盘助手v2.2.0.3 之后的版本才支持)
    `void` | `interceptTrimLeft(Context context, int num)` 截取左边字符串数量 Capture left side charactor string amount
    `void` | `interceptTrimRight(Context context, int num)` 截取右边字符串数量 Capture right side charactor string amount
    `void` | `logD(java.lang.String log)`
    `void` | `open(Context context, BarcodeUtility.ModuleType modul)` 打开指定功能 Switch on designated function
    `void` | `openKeyboardHelper(Context context)` 打开键盘助手功能总开关 Switch on main function switch of keyboardemulator
    `void` | `setBarcodeEncodingFormat(Context context, int format)` 设置条码编码格式 Setup barcode coding format
    `void` | `setContinuousScanIntervalTime(Context context, int intervalTime)` 设置连续扫描间隔时间 Setup continuous scanning duration
    `void` | `setContinuousScanTimeOut(Context context, int timeOut)` 设置连续扫描超时时间 Setup continuous scanning overtime duration
    `void` | `setOutputMode(Context context, int mode)` 设置输出模式 Setup ouput mode
    `void` | `setParam_zebra(Context context, int paramId, int paramValue)` 设置斑马扫描头参数,扫描头上电之后设置一次即可,扫描头断电之后失效。(备注：键盘助手v2.2.0.3 之后的版本才支持)
    `void` | `setPrefix(Context context, java.lang.String prefix)` 设置前缀 Setup prefix
    `void` | `setReleaseScan(Context context, boolean enable)` 松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
    `void` | `setScanFailureBroadcast(Context context, boolean enable)` 扫描失败是否发送广播 Send broadcast when scanning failure.
    `void` | `setScanOutTime(Context context, int time)` 设置超时时间 Setup overtime duration
    `void` | `setScanResultBroadcast(Context context, java.lang.String broadcastAction, java.lang.String extraName)` 设置接收扫描数据的广播 Setup broad cast of received scanning data
    `void` | `setSuffix(Context context, java.lang.String suffix)` 设置后缀 Setup suffix
    `void` | `startScan(Context context, BarcodeUtility.ModuleType modul)` 开始扫描 Start scanning
    `void` | `stopScan(Context context, BarcodeUtility.ModuleType modul)` 停止扫描 Stop scanning

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE

          public static final java.lang.String ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE

      See Also:
        Constant Field Values

    - #### SCANNER_RELEASESCAN

          public static final java.lang.String SCANNER_RELEASESCAN

      松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
      See Also:
        Constant Field Values

    - #### SCANNER_BROADCAST_ACTION

          public static final java.lang.String SCANNER_BROADCAST_ACTION

      接收扫描数据的广播ACTION
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUS

          public static final java.lang.String SCANNER_CONTINUOUS

      是否是连续扫描 Whether enable continuous scan
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUS_INTREVALTIME

          public static final java.lang.String SCANNER_CONTINUOUS_INTREVALTIME

      连续扫描时间间隔
      See Also:
        Constant Field Values

    - #### SCANNER_FORMAT_BARCODE

          public static final java.lang.String SCANNER_FORMAT_BARCODE

      条码格式 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030 Barcode format 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030
      See Also:
        Constant Field Values

    - #### SCANNER_BARCODENOTREPEAT

          public static final java.lang.String SCANNER_BARCODENOTREPEAT

      条码是否重复显示
      See Also:
        Constant Field Values

    - #### SCANNER_BROADCAST_EXTRA

          public static final java.lang.String SCANNER_BROADCAST_EXTRA

      接收扫描数据的广播的extra数据
      See Also:
        Constant Field Values

    - #### SCANNER_SCANKEYCODE_3

          public static final java.lang.String SCANNER_SCANKEYCODE_3

      扫描按键值 scan key code.
      See Also:
        Constant Field Values

    - #### SCANNER_SCANKEYCODE_1

          public static final java.lang.String SCANNER_SCANKEYCODE_1

      扫描按键值 scan key code.
      See Also:
        Constant Field Values

    - #### SCANNER_FILTERCHARS

          public static final java.lang.String SCANNER_FILTERCHARS

      条码数据需要过滤的字符串
      See Also:
        Constant Field Values

    - #### SCANNER_FAILUREBROADCAST

          public static final java.lang.String SCANNER_FAILUREBROADCAST

      扫描失败是否发送广播 Send broadcast when scanning failure.
      See Also:
        Constant Field Values

    - #### SCANNER_BARCODE_1D

          public static final java.lang.String SCANNER_BARCODE_1D

      1D是否已经开启
      See Also:
        Constant Field Values

    - #### SCANNER_VIBRATE

          public static final java.lang.String SCANNER_VIBRATE

      是否启用震动 whether vibrating when scanning success
      See Also:
        Constant Field Values

    - #### SCANNER_SUFFIX

          public static final java.lang.String SCANNER_SUFFIX

      条码后缀 barcode suffix.
      See Also:
        Constant Field Values

    - #### SCANNER_TAB

          public static final java.lang.String SCANNER_TAB

      是否启用tab
      See Also:
        Constant Field Values

    - #### SCANNER_ENTER

          public static final java.lang.String SCANNER_ENTER

      是否启用回车
      See Also:
        Constant Field Values

    - #### SCANNER_ENDINDEX

          public static final java.lang.String SCANNER_ENDINDEX

      后面去掉多少个字符
      See Also:
        Constant Field Values

    - #### SCANNER_FAILURESOUND

          public static final java.lang.String SCANNER_FAILURESOUND

      扫描失败是否播放声音 whether playing notification when scanning failure.
      See Also:
        Constant Field Values

    - #### SCANNER_OUTPUTMODE

          public static final java.lang.String SCANNER_OUTPUTMODE

      数据接收方式 0:键盘模拟 1:剪切板 2:系统广播 ouput mode 0: virtual key 1: clipboard 2: broadcast
      See Also:
        Constant Field Values

    - #### SCANNER_SOUND

          public static final java.lang.String SCANNER_SOUND

      扫描成功是否播放声音
      See Also:
        Constant Field Values

    - #### SCANNER_TIMEOUT

          public static final java.lang.String SCANNER_TIMEOUT

      扫描超时 scanning time out.
      See Also:
        Constant Field Values

    - #### SCANNER_PREFIX

          public static final java.lang.String SCANNER_PREFIX

      条码前缀 barcode prefix.
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUSTIMEOUT

          public static final java.lang.String SCANNER_CONTINUOUSTIMEOUT

      连续扫描超时时间 continuous scanning overtime duration
      See Also:
        Constant Field Values

    - #### SCANNER_KEYBORADHELPER_OPEN

          public static final java.lang.String SCANNER_KEYBORADHELPER_OPEN

      键盘助手总开关是否已经打开
      See Also:
        Constant Field Values

    - #### SCANNER_CONTINUOUSMODE

          public static final java.lang.String SCANNER_CONTINUOUSMODE

      是否启用了连续扫描模式
      See Also:
        Constant Field Values

    - #### SCANNER_ILLUMINATIONPOWERLEVEL

          public static final java.lang.String SCANNER_ILLUMINATIONPOWERLEVEL

      4710 扫描头亮度等级
      See Also:
        Constant Field Values

    - #### SCANNER_STARTINDEX

          public static final java.lang.String SCANNER_STARTINDEX

      前面去掉多少个字符
      See Also:
        Constant Field Values

    - #### SCANNER_BARCODE_2D

          public static final java.lang.String SCANNER_BARCODE_2D

      2D是否已经开启
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getInstance

          public static BarcodeUtility getInstance()

      获取条码操作实例 Acquire barcode operation Instance.

    - #### open

          public void open(Context context,
                           BarcodeUtility.ModuleType modul)

      打开指定功能 Switch on designated function
      Parameters:
        `context` -
        `modul` - 功能模块

    - #### close

          public void close(Context context,
                            BarcodeUtility.ModuleType modul)

      关闭指定功能 Switch off designated function
      Parameters:
        `context` -
        `modul` - 功能模块

    - #### startScan

          public void startScan(Context context,
                                BarcodeUtility.ModuleType modul)

      开始扫描 Start scanning
      Parameters:
        `modul` - 功能模块

    - #### stopScan

          public void stopScan(Context context,
                               BarcodeUtility.ModuleType modul)

      停止扫描 Stop scanning
      Parameters:
        `context` -
        `modul` - 功能模块

    - #### setOutputMode

          public void setOutputMode(Context context,
                                    int mode)

      设置输出模式 Setup ouput mode
      Parameters:
        `context` -
        `mode` - 0:模拟按键 1:剪切板 2:广播 mode 0: virtual key 1: clipboard 2: broadcast

    - #### setScanOutTime

          public void setScanOutTime(Context context,
                                     int time)

      设置超时时间 Setup overtime duration
      Parameters:
        `context` -
        `time` - 超时时间，单位秒 time overtime time, unit is second

    - #### setScanResultBroadcast

          public void setScanResultBroadcast(Context context,
                                             java.lang.String broadcastAction,
                                             java.lang.String extraName)

      设置接收扫描数据的广播 Setup broad cast of received scanning data
      Parameters:
        `context` -
        `broadcastAction` - 接收扫描数据的action
        `extraName` - Intent返回的扩展数据项目名称

    - #### openKeyboardHelper

          public void openKeyboardHelper(Context context)

      打开键盘助手功能总开关 Switch on main function switch of keyboardemulator
      Parameters:
        `context` -

    - #### closeKeyboardHelper

          public void closeKeyboardHelper(Context context)

      关闭键盘助手功能总开关 Switch off main function switch of keyboardemulator
      Parameters:
        `context` -

    - #### enablePlaySuccessSound

          public void enablePlaySuccessSound(Context context,
                                             boolean isSuccessSound)

      是否播放成功的提示音 whether playing notification when scanning success.
      Parameters:
        `context` -
        `isSuccessSound` - true:播放成功提示音,false:不播放成功提示音 true: enable false:disable

    - #### enablePlayFailureSound

          public void enablePlayFailureSound(Context context,
                                             boolean isFailureSound)

      扫描失败是否播放提示音 whether playing notification when scanning failure.
      Parameters:
        `context` -
        `isFailureSound` - true:播放失败提示音,false:不播放失败提示音 true: enable false:disable

    - #### enableVibrate

          public void enableVibrate(Context context,
                                    boolean isVibrate)

      扫描成功是否震动提示 whether vibrating when scanning success
      Parameters:
        `context` -
        `isVibrate` - true:震动,false:不震动 true: enable false:disable

    - #### enableEnter

          public void enableEnter(Context context,
                                  boolean isEnter)

      是否启用回车 Whether enable Enter function
      Parameters:
        `context` -
        `isEnter` - true: 启用回车 false:不启用回车 true: enable false:disable

    - #### enableTAB

          public void enableTAB(Context context,
                                boolean isTab)

      是否启用TAB Whether enable TAB function
      Parameters:
        `context` -
        `isTab` - true: 启用回车 false:不启用回车 true: enable false:disable

    - #### setSuffix

          public void setSuffix(Context context,
                                java.lang.String suffix)

      设置后缀 Setup suffix
      Parameters:
        `context` -
        `suffix` - 后缀字符

    - #### setPrefix

          public void setPrefix(Context context,
                                java.lang.String prefix)

      设置前缀 Setup prefix
      Parameters:
        `context` -
        `prefix` - 前缀字符

    - #### interceptTrimLeft

          public void interceptTrimLeft(Context context,
                                        int num)

      截取左边字符串数量 Capture left side charactor string amount
      Parameters:
        `context` -
        `num` - 左边截取的字符数量

    - #### interceptTrimRight

          public void interceptTrimRight(Context context,
                                         int num)

      截取右边字符串数量 Capture right side charactor string amount
      Parameters:
        `context` -
        `num` - 右边截取的字符数量

    - #### filterCharacter

          public void filterCharacter(Context context,
                                      java.lang.String chars)

      过滤字符串 Filter charactor string
      Parameters:
        `context` -
        `chars` - 过滤的字符

    - #### setBarcodeEncodingFormat

          public void setBarcodeEncodingFormat(Context context,
                                               int format)

      设置条码编码格式 Setup barcode coding format
      Parameters:
        `context` -
        `format` - 0: Default 1: ASCII 2:GB2312 3:UTF8 4:Unicode 10:GBK, 11:GB18030

    - #### enableContinuousScan

          public void enableContinuousScan(Context context,
                                           boolean isContinuous)

      启用连续扫描 Enable continuous scan
      Parameters:
        `context` -
        `isContinuous` - true: 连续扫描 false：单次扫描 true: enable false：disable

    - #### setContinuousScanIntervalTime

          public void setContinuousScanIntervalTime(Context context,
                                                    int intervalTime)

      设置连续扫描间隔时间 Setup continuous scanning duration
      Parameters:
        `context` -
        `intervalTime` - 间隔时间，单位毫秒 interval Time, (unit: millisecond)

    - #### setContinuousScanTimeOut

          public void setContinuousScanTimeOut(Context context,
                                               int timeOut)

      设置连续扫描超时时间 Setup continuous scanning overtime duration
      Parameters:
        `context` -
        `timeOut` - 超时时间，单位秒 time Out(unit:second)

    - #### setScanFailureBroadcast

          public void setScanFailureBroadcast(Context context,
                                              boolean enable)

      扫描失败是否发送广播 Send broadcast when scanning failure.
      Parameters:
        `context` -
        `enable` - true:发送 false：不发送

    - #### setReleaseScan

          public void setReleaseScan(Context context,
                                     boolean enable)

      松开扫描按键是否停止扫描 loose scanning button to stop scanning or not
      Parameters:
        `context` -
        `enable` - true:停止扫描 false：不停止扫描

    - #### setParam_zebra

          public void setParam_zebra(Context context,
                                     int paramId,
                                     int paramValue)

      设置斑马扫描头参数,扫描头上电之后设置一次即可,扫描头断电之后失效。(备注：键盘助手v2.2.0.3 之后的版本才支持)
      Parameters:
        `context` -
        `paramId` - id
        `paramValue` - value

    - #### getKeyboardHelperParam

          public void getKeyboardHelperParam(Context context)

      获取键盘助手状态值,通过action接收数据`ACTION_SCAN_KEYBOARD_HELPER_PARAM_RESPONSE`.(备注：键盘助手v2.2.0.3 之后的版本才支持)
      Parameters:
        `context` -

    - #### logD

          public void logD(java.lang.String log)