SWITCH_DATACAPTURE
DataWedge 11.2 で導入。
実行時に次の機能を切り替えるために使用します。
- バーコード スキャンと バーコード強調 (バーコードを強調表示してアイテムの検索を補助するために、バーコード スキャンとビューファインダ (またはプレビュー画面) の使用を切り替える機能など)。
- ワークフロー入力オプション (同じアプリで運転免許証をスキャンしナンバー プレートを読み取るなど)。
注: この API によって構成された設定は、プロファイルが別のプロファイルに切り替わるまで有効です。
関数プロトタイプ
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("APPLICATION_PACKAGE", getPackageName());
i.setPackage("com.symbol.datawedge");
i.putExtra("SEND_RESULT", "LAST_RESULT");
i.putExtra("com.symbol.datawedge.api.SWITCH_DATACAPTURE", "<Input plugin name>");
Bundle paramList = new Bundle();
paramList.putString("scanner_selection_by_identifier", "<Selected scanner>"); //INTERNAL_IMAGER
paramList.putString("<Param1ID>", "<Param1Value>");
i.putExtra("PARAM_LIST", paramList);
sendBroadcast(i);
パラメータ
ACTION [String]: "com.symbol.datawedge.api.ACTION"
EXTRA_DATA [String]: "APPLICATION_PACKAGE" – 呼び出し元のアプリケーション パッケージ名
EXTRA_DATA [String]: "com.symbol.datawedge.api.SWITCH_DATACAPTURE"
PACKAGE: com.symbol.datawedge
EXTRA_DATA [String]: "PARAM_LIST"–入力プラグインに渡されるパラメータ リスト
結果コード
アプリにインテントエクストラ SEND_RESULT
が含まれている場合、DataWedge は次のエラー コードを返します。
- DATAWEDGE_DISABLED - DataWedge が無効です
- PROFILE_DISABLED - プロファイルが無効です
- PLUGIN_DISABLED - スキャナ プラグインが無効になっています
- NO_ACTIVE_PROFILE – アクティブなプロファイルはロードされていません
- PLUGIN_NOT_SUPPORTED – 指定されたプラグインはデバイスではサポートされていません
- INVALID_WORKFLOW – 無効なワークフロー ID が指定されました
- UNLICENSED_FEATURE – 切り替え先のパラメータまたは機能に対して有効なライセンスがありません
- PARAMETER_INVALID - パラメータが無効です
- PARAMETER_NOT_SUPPORTED - パラメータはサポートされていません
- VALUE_INVALID - パラメータに指定された値が無効です
- VALUE_NOT_SUPPORTED - パラメータに指定された値はサポートされていません
コード例
バーコード スキャンと強調を切り替えます
このサンプル コードは、実行時にバーコード スキャンからバーコード強調に切り替える方法を示します。
public void onClickHighlight(View view) {
//Specify the DataWedge action and SWITCH_DATACAPTURE API parameters
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("APPLICATION_PACKAGE", getPackageName());
i.setPackage("com.symbol.datawedge");
i.putExtra("SEND_RESULT", "LAST_RESULT");
i.putExtra("com.symbol.datawedge.api.SWITCH_DATACAPTURE", "BARCODE");
Bundle paramList = new Bundle();
//Specify the scanner to use (Only internal imager and camera are supported currently)
paramList.putString("scanner_selection_by_identifier", "INTERNAL_IMAGER");
//Enable barcode highlighting
paramList.putString("barcode_highlighting_enabled", "true");
//Create a barcode highlighting Rule 1 [Start]
Bundle rule1 = new Bundle();
rule1.putString("rule_name", "Rule1");
Bundle rule1Criteria = new Bundle();
//Set the criteria/condition. Specify the contains parameter.
Bundle bundleContains1 = new Bundle();
bundleContains1.putString("criteria_key", "contains");
bundleContains1.putString("criteria_value", "090986");
//Container is just one parameter of identifier group.
// There are other params such as ignore case, min length, max length
ArrayList<Bundle> identifierParamList = new ArrayList<>();
identifierParamList.add(bundleContains1);
//Add the parameters of "identifier" group as a ParcelableArrayList to criteria list
rule1Criteria.putParcelableArrayList("identifier", identifierParamList);
//Add the criteria to Rule bundle
rule1.putBundle("criteria", rule1Criteria);
//Set up the action bundle by specifying the color to be highlight
Bundle bundleFillColor = new Bundle();
bundleFillColor.putString("action_key", "fillcolor");
bundleFillColor.putString("action_value", "#CEF04E6E");
ArrayList<Bundle> rule1Actions = new ArrayList<>();
rule1Actions.add(bundleFillColor);
rule1.putParcelableArrayList("actions", rule1Actions);
//Create a barcode highlighting Rule 1 [Finish]
//Create a barcode highlighting Rule 2 [Start]
Bundle rule2 = new Bundle();
rule2.putString("rule_name", "Rule2");
Bundle rule2Criteria = new Bundle();
Bundle bundleContains2 = new Bundle();
bundleContains2.putString("criteria_key", "contains");
bundleContains2.putString("criteria_value", "7777");
ArrayList<Bundle> identifierParamList2 = new ArrayList<>();
identifierParamList2.add(bundleContains2);
rule2Criteria.putParcelableArrayList("identifier", identifierParamList2);
rule2.putBundle("criteria", rule2Criteria);
Bundle rule2BundleStrokeColor = new Bundle();
rule2BundleStrokeColor.putString("action_key", "fillcolor");
rule2BundleStrokeColor.putString("action_value", "#CE7F2714");
ArrayList<Bundle> rule2Actions = new ArrayList<>();
rule2Actions.add(rule2BundleStrokeColor);
rule2.putParcelableArrayList("actions", rule2Actions);
//Create a barcode highlighting Rule 1 [Finish]
//Add the two created rules to the rule list
ArrayList<Bundle> ruleList = new ArrayList<>();
ruleList.add(rule1);
ruleList.add(rule2);
//Assign the rule list to barcode_overlay parameter
Bundle ruleBundlebarcodeOverlay = new Bundle();
ruleBundlebarcodeOverlay.putString("rule_param_id", "barcode_overlay");
ruleBundlebarcodeOverlay.putParcelableArrayList("rule_list", ruleList);
ArrayList<Bundle> ruleParamList = new ArrayList<>();
ruleParamList.add(ruleBundlebarcodeOverlay);
paramList.putParcelableArrayList("rules", ruleParamList);
i.putExtra("PARAM_LIST", paramList);
sendBroadcast(i);
}
public void onClickRegular(View view) {
//Specify the DataWedge action and SWITCH_DATACAPTURE API parameters
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("APPLICATION_PACKAGE", getPackageName());
i.setPackage("com.symbol.datawedge");
i.putExtra("SEND_RESULT", "LAST_RESULT");
i.putExtra("com.symbol.datawedge.api.SWITCH_DATACAPTURE", "BARCODE");
Bundle paramList = new Bundle();
//Specify the scanner to use (Only internal imager and camera are supported currently)
paramList.putString("scanner_selection_by_identifier", "INTERNAL_IMAGER");
//Disable barcode highlighting
paramList.putString("barcode_highlighting_enabled", "false");
i.putExtra("PARAM_LIST", paramList);
sendBroadcast(i);
}
ワークフロー オプションを切り替えます
このサンプル コードは、実行時に識別ドキュメントのスキャンをメーター読み取りに切り替える方法を示しています。
public void switchToIDScanning()
{
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("APPLICATION_PACKAGE", getPackageName());
i.setPackage("com.symbol.datawedge");
i.putExtra("SEND_RESULT","LAST_RESULT");
i.putExtra("com.symbol.datawedge.api.SWITCH_DATACAPTURE", "WORKFLOW");
Bundle paramList = new Bundle();
paramList.putString("workflow_name","id_scanning");
paramList.putString("workflow_input_source","2");
Bundle paramSet1 = new Bundle();
paramSet1.putString("module","IDDecoderModule");
Bundle moduleAParams = new Bundle();
moduleAParams.putString("session_timeout", "25000");
paramSet1.putBundle("module_params",moduleAParams);
ArrayList<Bundle> paramSetList = new ArrayList<>();
paramSetList.add(paramSet1);
paramList.putParcelableArrayList("workflow_params", paramSetList);
i.putExtra("PARAM_LIST", paramList);
sendBroadcast(i);
}
public void switchToMeterReading()
{
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("APPLICATION_PACKAGE", getPackageName());
i.setPackage("com.symbol.datawedge");
i.putExtra("SEND_RESULT","LAST_RESULT");
i.putExtra("com.symbol.datawedge.api.SWITCH_DATACAPTURE", "WORKFLOW");
Bundle paramList = new Bundle();
paramList.putString("workflow_name","meter_reading");
paramList.putString("workflow_input_source","2");
Bundle paramSet1 = new Bundle();
paramSet1.putString("module","MeterReaderModule");
Bundle moduleAParams = new Bundle();
moduleAParams.putString("session_timeout", "15000");
paramSet1.putBundle("module_params",moduleAParams);
ArrayList<Bundle> paramSetList = new ArrayList<>();
paramSetList.add(paramSet1);
paramList.putParcelableArrayList("workflow_params", paramSetList);
i.putExtra("PARAM_LIST", paramList);
sendBroadcast(i);
}
関連項目:
Zebra Support Central | インテグレータ ガイド、製品マニュアル、ソフトウェア ダウンロードおよびサポート
LaunchPad | Zebra 開発者コミュニティ
インテント | Android 開発者
インテントおよびインテント フィルタ | Android 開発者
Android インテント | チュートリアル