霍尼韦尔安卓系统OdooApp数据扫码消息广播API
欧度软件数据收集Intent API 可在 Honeywell Android 手机终端与平板电脑使用。它通过提供简单易用的系统消息 API 即可对扫码硬件模块的访问,而无需安装复杂的 Honeywell SDK 来深度集成。
OdooApp先发送一个Intent事件来启动扫描程序并配置扫码参数,再发送另一个Intent事件来结束扫描程序。还有可选的第三个Intent事件用来指定内外部扫码设备。
OdooApp也需要实现一个Intent事件监听器,以从扫描头接收条形码或二维码的解析结果事件处理程序。
Odoo安卓应用程序代码实施清单:
Android Manifest
<uses-permission android:name="com.honeywell.decode.permission.DECODE" />
Activity.onResume()
为激光扫码结果创建 Intent 接收器。发送 intent 以启动红外扫描程序。
Activity.onPause()
发送 intent 以主动结束扫描程序。
ACTION_CLAIM_SCANNER事件:
全称: com.honeywell.aidc.action.ACTION_CLAIM_SCANNER
使用扫码硬件模块 com.honeywell.aidc.extra.EXTRA_SCANNERdcs.scanner.imager:使用内置扫码模块。
dcs.scanner.ring:使用外部连接扫描枪。
使用扫码配置文件 com.honeywell.aidc.extra.EXTRA_PROFILE
扫描配置文件包含扫码模组的一系列详细属性参数设置。要在设备上创建配置文件,请转到 Android 系统 设置 > 扫描。创建配置文件时,请输入OdooApp名称。您的应用程序将按此名称选择配置文件。
创建 ACTION_CLAIM_SCANNER Intent 时,将 EXTRA_PROFILE extra string 值设置为OdooApp。
使用 EZConfig 进行配置,扫描配置文件处于DataCollectionService.xml。
如要在 Scanning 设置中使用 Default 配置文件,请将其设置为 “DEFAULT”。如果未提供配置文件名称,扫描头将使用出厂默认设置。
使用扫码属性参数 com.honeywell.aidc.extra.EXTRA_PROPERTIES
创建 ACTION_CLAIM_SCANNER Intent 时,设置 EXTRA_PROPERTIES Intent extra Bundle。Bundle 包含应用程序所需的所有扫描属性。属性名称和值记录在 com.honeywell.aidc.BarcodeReader 类中。
如果 EXTRA_PROFILE 和 EXTRA_PROPERTIES 都同时用于定义扫码属性,则 EXTRA_PROPERTIES 优先并覆盖所选配置文件的对应属性参数。
ACTION_RELEASE_SCANNER 事件:
全称: com.honeywell.aidc.action.ACTION_RELEASE_SCANNER
OdooApp发送此 intent 以释放扫描头并停止接收扫码结果数据。
ACTION_CONTROL_SCANNER事件:
全称: com.honeywell.aidc.action.ACTION_CONTROL_SCANNER
OdooApp发送此 intent 以启动扫描程序。
扫码工作com.honeywell.aidc.extra.EXTRA_SCAN
设置为 true 以开始或继续扫描,设置为 false 可停止扫描,大多数方案只需要此 extra即可。
扫码准星com.honeywell.aidc.extra.EXTRA_AIM
指定是打开还是关闭扫描仪瞄准器。这是可选的,默认值为 EXTRA_SCAN 的值。
扫码照明com.honeywell.aidc.extra.EXTRA_LIGHT
指定是打开还是关闭扫描仪照明。这是可选的,默认值为 EXTRA_SCAN 的值。
扫码解码com.honeywell.aidc.extra.EXTRA_DECODE
指定是打开还是关闭解码操作。这是可选的,默认值为 EXTRA_SCAN的值。
Barcode解析完成广播事件:
OdooApp在成功扫描条码后收到PDA广播的Intent。其事件动作名称由 DPR_DATA_INTENT_ACTION属性参数决定。所有应用程序可以为此属性指定自己的操作名称,例如“com.odoo.app.action.BARCODE_DATA”,否则默认为"com.honeywell.scan.broadcast"广播动作
"data" (string): 解码数据字符串
"charset" (string) : 解码数据字符集
"dataBytes" (byte[]) : 原始条形码二进制数据
"timestamp" (string) : 解码数据时间戳
"aimId" (string): AIMID标准符号表示标识符 "codeId" (string) : Honeywell系统符号表示标识符 "version" (int) : 数据解码API版本号
"scanner" (未知) : 可能是连接外部扫码枪的名称
也可以在中国特色主菜单企业设置里进行全局的扫码设置,比如将扫码结果广播action修改为odoo.app.scan,此时默认的extras信息如下:
"Length" (number): 解码数据字符串长度
"scanner_result" (string): 解码数据字符串
"scanner_result_byte" (byte[]) : 原始二维码二进制数据
"special_keys" (string) : 特殊键码
"decodeTime" (number): 解码时间毫秒数
"lastDecodeTime" (number): 最后解码时间毫秒数
"AimModifier" (number): 未知,如49
"AimID" (number): AIMID标准符号表示标识符,如81
"CodeID" (number): Honeywell系统符号表示标识符,如二维码为115
"isFocus" (boolean): 是否焦点
还可以将原生扫描结果广播key修改成任意方便集成的名称,比如将标准key为data的最终解码结果扩展出一个新的code,前端就可以统一硬编码快捷获取扫码内容。
欧度软件安卓MainActivity核心参考代码:
package com.honeywell.sample.intentapisample;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "IntentApiSample";
private static final String ACTION_BARCODE_DATA = "com.honeywell.sample.action.BARCODE_DATA";
/**
* Honeywell DataCollection Intent API
* Claim scanner
* Permissions:
* "com.honeywell.decode.permission.DECODE"
*/
private static final String ACTION_CLAIM_SCANNER =
"com.honeywell.aidc.action.ACTION_CLAIM_SCANNER";
/**
* Honeywell DataCollection Intent API
* Release scanner claim
* Permissions:
* "com.honeywell.decode.permission.DECODE"
*/
private static final String ACTION_RELEASE_SCANNER =
"com.honeywell.aidc.action.ACTION_RELEASE_SCANNER";
/**
* Honeywell DataCollection Intent API
* Optional. Sets the scanner to claim. If scanner is not available or if extra is not used,
* DataCollection will choose an available scanner.
* Values : String
* "dcs.scanner.imager" : Uses the internal scanner
* "dcs.scanner.ring" : Uses the external ring scanner
*/
private static final String EXTRA_SCANNER = "com.honeywell.aidc.extra.EXTRA_SCANNER";
/**
* Honeywell DataCollection Intent API
* Optional. Sets the profile to use. If profile is not available or if extra is not used,
* the scanner will use factory default properties (not "DEFAULT" profile properties).
* Values : String
*/
private static final String EXTRA_PROFILE = "com.honeywell.aidc.extra.EXTRA_PROFILE";
/**
* Honeywell DataCollection Intent API
* Optional. Overrides the profile properties (non-persistent) until the next scanner claim.
* Values : Bundle
*/
private static final String EXTRA_PROPERTIES = "com.honeywell.aidc.extra.EXTRA_PROPERTIES";
private TextView textView;
private BroadcastReceiver barcodeDataReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_BARCODE_DATA.equals(intent.getAction())) {
/*
These extras are available:
"version" (int) = Data Intent Api version
"aimId" (String) = The AIM Identifier
"charset" (String) = The charset used to convert "dataBytes" to "data" string
"codeId" (String) = The Honeywell Symbology Identifier
"data" (String) = The barcode data as a string
"dataBytes" (byte[]) = The barcode data as a byte array
"timestamp" (String) = The barcode timestamp
*/
int version = intent.getIntExtra("version", 0);
if (version >= 1) {
String aimId = intent.getStringExtra("aimId");
String charset = intent.getStringExtra("charset");
String codeId = intent.getStringExtra("codeId");
String data = intent.getStringExtra("data");
byte[] dataBytes = intent.getByteArrayExtra("dataBytes");
String dataBytesStr = bytesToHexString(dataBytes);
String timestamp = intent.getStringExtra("timestamp");
String text = String.format(
"Data:%s\n" +
"Charset:%s\n" +
"Bytes:%s\n" +
"AimId:%s\n" +
"CodeId:%s\n" +
"Timestamp:%s\n",
data, charset, dataBytesStr, aimId, codeId, timestamp);
setText(text);
}
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.textView);
}
@Override
protected void onResume() {
super.onResume();
registerReceiver(barcodeDataReceiver, new IntentFilter(ACTION_BARCODE_DATA));
claimScanner();
}
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(barcodeDataReceiver);
releaseScanner();
}
private void claimScanner() {
Bundle properties = new Bundle();
properties.putBoolean("DPR_DATA_INTENT", true);
properties.putString("DPR_DATA_INTENT_ACTION", ACTION_BARCODE_DATA);
sendBroadcast(new Intent(ACTION_CLAIM_SCANNER)
.setPackage("com.intermec.datacollectionservice")
.putExtra(EXTRA_SCANNER, "dcs.scanner.imager")
.putExtra(EXTRA_PROFILE, "MyProfile1")
.putExtra(EXTRA_PROPERTIES, properties)
);
}
private void releaseScanner() {
sendBroadcast(new Intent(ACTION_RELEASE_SCANNER)
.setPackage("com.intermec.datacollectionservice")
);
}
private void setText(final String text) {
if (textView != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
textView.setText(text);
}
});
}
}
private String bytesToHexString(byte[] arr) {
String s = "[]";
if (arr != null) {
s = "[";
for (int i = 0; i < arr.length; i++) {
s += "0x" + Integer.toHexString(arr[i]) + ", ";
}
s = s.substring(0, s.length() - 2) + "]";
}
return s;
}
}
Honeywell系统符号表示标识符目录列表
Symbology |
Code Id |
|
DOTCODE |
. |
|
CODE1 |
1 |
|
MERGED_COUPON |
; |
|
CODE39_BASE32, CODE32, ITALIAN PHARMACODE, PARAF |
< |
|
LABELCODE_IV |
> |
|
LABELCODE_V |
< |
|
TRIOPTIC |
= |
|
KOREA_POST |
? |
|
INFOMAIL |
, |
|
EAN13_ISBN |
` |
|
SWEEDISH_POST |
[ |
|
RM_MAILMARK |
| |
|
BRAZIL_POST |
] |
|
AUS_POST |
A |
|
BRITISH_POST |
B |
|
CANADIAN_POST |
C |
|
EAN8 |
D |
|
UPCE |
E |
|
BC412 |
G |
|
HAN_XIN_CODE |
H |
|
GS1_128 |
I |
|
JAPAN_POST |
J |
|
KIX_CODE |
K |
|
PLANET_CODE |
L |
|
USPS_4_STATE, INTELLIGENT_MAIL |
M |
|
UPU_4_STATE, ID_TAGS |
N |
|
OCR |
O |
|
POSTNET |
P |
|
HK25, CHINA_POST |
Q |
|
MICROPDF |
R |
|
SECURE_CODE |
S |
|
TLC39 |
T |
|
ULTRACODE |
U |
|
CODABLOCK_A |
V |
|
POSICODE |
W |
|
GRID_MATRIX |
X |
|
NEC25 |
Y |
|
MESA |
Z |
|
CODABAR |
a |
|
CODE39 |
b |
|
UPCA |
c |
|
EAN13 |
d |
|
I25 |
e |
|
S25 (2BAR and 3BAR) |
f |
|
MSI |
g |
|
CODE11 |
h |
|
CODE93 |
i |
|
CODE128 |
j |
|
UNUSED |
k |
|
CODE49 |
l |
|
M25 |
m |
|
PLESSEY |
n |
|
CODE16K |
o |
|
CHANNELCODE |
p |
|
CODABLOCK_F |
q |
|
PDF417 |
r |
|
QRCODE |
s |
|
MICROQR_ALT |
- |
|
TELEPEN |
t |
|
CODEZ |
u |
|
VERICODE |
v |
|
DATAMATRIX |
w |
|
MAXICODE |
x |
|
RSS |
y |
|
GS1_DATABAR |
y |
|
GS1_DATABAR_LIM |
{ |
|
GS1_DATABAR_EXP |
} |
|
COMPOSITE |
y |
|
AZTEC_CODE |
z |
浙公网安备 33010602011771号