新聞資訊
工業(yè)手持PDA的領(lǐng)導(dǎo)者斑馬技術(shù)
在Apk中如何快速的輸入數(shù)據(jù)
傳統(tǒng)的光標(biāo)位置,鍵盤仿真輸入數(shù)據(jù)
較容易替代,
遇到復(fù)雜問題不容易解決,
例如掃描前清空輸入框,
或是掃描數(shù)據(jù)全選的需求
ZEBRA 也支持更加安全可靠
功能更加豐富的Intent 廣播模式
將掃描數(shù)據(jù)送入輸入框
DataWedge是在所有Zebra Android設(shè)備上運行的服務(wù)
可被其他應(yīng)用程序用來控制數(shù)據(jù)捕獲,
而無需直接訪問DataWedge UI。
可以控制大大方便DataWedge的數(shù)據(jù)捕獲
參考《DataWedge API 接口說明》
如果有異議以官網(wǎng)內(nèi)容為準(zhǔn)
本手冊內(nèi)容原版信息
https://techdocs.zebra.com/datawedge/8-2/guide/api/

相關(guān)官方開發(fā)樣例和源碼參考
https://techdocs.zebra.com/datawedge/8-2/guide/samples/

或參考Github網(wǎng)站
https://github.com/Zebra/techdocs-archive


通過指定不同的Bundle,我們可以實現(xiàn)不同框架下配置屬性的快速修改
1. 創(chuàng)建一個配置文件。如果未創(chuàng)建和分配任何配置文件,則DataWedge將使用Profile0,但我們建議為你的apk單獨創(chuàng)建Profile進行管理//創(chuàng)建一個獨立的profile名字為 zebraIntent
private void createProfile()
{
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.CREATE_PROFILE", "zebraIntent");
this.sendBroadcast(i);
}
2. 目標(biāo)應(yīng)用程序關(guān)聯(lián)新建的profile一個Activity不能關(guān)聯(lián)到兩個profile。應(yīng)用運行中可以通過使用SwitchProfile來切換不同的profile來實現(xiàn)不同的配置。/* * DataWedge設(shè)置關(guān)聯(lián)應(yīng)用程序zebrascan 到profile文件zebraIntent *
/public void setAppListConfiguration() {
Bundle bMain = new Bundle();
Bundle app1 = new Bundle();
app1.putString("PACKAGE_NAME","com.example.zebrascan");app1.putStringArray("ACTIVITY_LIST", new String[]{"*"});
bMain.putParcelableArray("APP_LIST", new Bundle[]{app1});
bMain.putString("PROFILE_NAME","zebraIntent");
bMain.putString("PROFILE_ENABLED","true");
bMain.putString("CONFIG_MODE","CREATE_IF_NOT_EXIST");
Intent i = new Intent();i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SET_CONFIG", bMain);
i.putExtra("SEND_RESULT", "true");
i.putExtra("COMMAND_IDENTIFIER", "APP_LIST");
this.sendBroadcast(i);
}
也可以通過修改profile來實現(xiàn)設(shè)置的切換,例如下面通過修改aim_type 的值,實現(xiàn)按鍵“連續(xù)掃描”的的設(shè)置。我們可以在 Set Config 網(wǎng)頁中,查詢詳細(xì)的設(shè)置項說明。(此節(jié)為可選說明)/* * DataWedge設(shè)置連續(xù)掃描 Intent輸出 *
/public void setContinuousConfiguration() {
Bundle bMain = new Bundle();Bundle bConfig = new Bundle();Bundle bParams = new Bundle();
bParams.putString("scanner_selection","auto");
bParams.putString("aim_type","5"); //AIM_TYPE 0單一掃描,5連續(xù)掃描bConfig.putBundle("PARAM_LIST",
bParams);bConfig.putString("PLUGIN_NAME","BARCODE");
bConfig.putString("RESET_CONFIG","true");
bMain.putBundle("PLUGIN_CONFIG", bConfig);bMain.putString("PROFILE_NAME","zebraIntent");bMain.putString("PROFILE_ENABLED","true");bMain.putString("CONFIG_MODE","CREATE_IF_NOT_EXIST");
Intent i = new Intent();i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SET_CONFIG",bMain);
i.putExtra("SEND_RESULT", "true");
i.putExtra"COMMAND_IDENTIFIER", "BARCODE_SETTING_API");
this.sendBroadcast(i);
}
3. DataWedge設(shè)置并啟用Intent輸出設(shè)置“intent_output_enabled” 生效,此profile啟用intent傳遞數(shù)據(jù)。定義Intent操作字串"com.symbol.mybroadcast",類別字串"com.symbol.category.DEFAULT"。
/* DataWedge設(shè)置并啟用Intent輸出 *
/public void setIntentOutputPluginConfiguration()
{Bundle bMain = new Bundle();
Bundle bConfig = new Bundle();
Bundle bParams = new Bundle();
bParams.putString("intent_output_enabled","true");
bParams.putStrin("intent_action","com.symbol.mybroadcast");
bParams.putString"intent_category","com.symbol.category.DEFAULT");
bParams.putInt"intent_delivery",2); //Use "0" for Start Activity, "1" for Start Service, "2" for Broadcast
bConfig.putString("PLUGIN_NAME", "INTENT");
bConfig.putString("RESET_CONFIG","false");
bConfig.putBundle("PARAM_LIST", bParams);
bMain.putBundle("PLUGIN_CONFIG", bConfig);
bMain.putString("PROFILE_NAME","zebraIntent");
bMain.putString("PROFILE_ENABLED","true");
bMain.putString("CONFIG_MODE","CREATE_IF_NOT_EXIST");
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SET_CONFIG",bMain);
i.putExtra("SEND_RESULT", "true");
i.putExtra("COMMAND_IDENTIFIER", "INTENT_API");
this.sendBroadcast(i);
}
4. 設(shè)置 intent 的操作字串com.symbol.datawedge.data_string 是通過Intent捕獲到的Datawedge返回的條碼數(shù)據(jù)(字串格式)名稱,無法修改請注意。
//定義Intent的操作字串private String INTENT_ACTION = "com.symbol.mybroadcast";
//定義Intent的類別字串
private String INTENT_CATEGORY = "com.symbol.category.DEFAULT";
//API中定義,通過Intent捕獲到的Datawedge返回的條碼數(shù)據(jù)(字串格式)名稱private String DATA_STRING_TAG = "com.symbol.datawedge.data_string";
其他
?將DataWedge Profile的添加和配置放在程序中,通過API來實現(xiàn),這樣一方面可以避免手動配置設(shè)備的繁瑣工作,也可以避免手動設(shè)置失誤可能帶來的錯誤。
?無論是使用鍵盤輸出,還是Intent輸出,建議用戶開發(fā)人員不要直接使用Profile0,建立并關(guān)聯(lián)自己的配置文件,避免其他程序的操作造成無法預(yù)測的影響。
感謝斑馬SE:Max & Wangjian 的指導(dǎo)