Switch Data Capture

DataWedge 11.2

SWITCH_DATACAPTURE

Introduced in DataWedge 11.2.

Used to switch between the following at runtime:

  • Barcode scanning and Barcode Highlighting, e.g. to have the ability to alternate between scanning barcodes and using the viewfinder (or preview screen) to highlight barcodes to aid in finding items.
  • Workflow Input options, e.g. to scan a driver license and read a license plate in the same app.

Note: Settings configured by this API remain in effect until the Profile is switched to a different Profile.

Function Prototype

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);

Parameters

ACTION [String]: "com.symbol.datawedge.api.ACTION"

EXTRA_DATA [String]: "APPLICATION_PACKAGE" – calling application package name

EXTRA_DATA [String]: "com.symbol.datawedge.api.SWITCH_DATACAPTURE"

PACKAGE: com.symbol.datawedge

EXTRA_DATA [String]: "PARAM_LIST" – param list to be passed to the input plugin

Result Codes

DataWedge returns the following error codes if the app includes the intent extras SEND_RESULT:

  • DATAWEDGE_DISABLED - DataWedge is disabled
  • PROFILE_DISABLED - Profile is disabled
  • PLUGIN_DISABLED - Scanner plug-in is disabled
  • NO_ACTIVE_PROFILE – no active profile loaded
  • PLUGIN_NOT_SUPPORTED – specified plugin is not supported on the device
  • INVALID_WORKFLOW – invalid Workflow ID specified
  • UNLICENSED_FEATURE – no valid license available for the parameter or feature being switched to
  • PARAMETER_INVALID - the parameter is invalid
  • PARAMETER_NOT_SUPPORTED - the parameter is not supported
  • VALUE_INVALID - the value for the parameter is invalid
  • VALUE_NOT_SUPPORTED - the value for the parameter is not supported

Example Code

Switch between barcode scanning and highlighting

This sample code demonstrates how to switch from barcode scanning to barcode highlighting at runtime:

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);
}

Switch between workflow options

This sample code demonstrates how to switch between identification document scanning to meter reading at runtime:

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);
}

SEE ALSO:

Zebra Support Central | Integrator Guides, Product Manuals, Software Downloads and Support

LaunchPad | Zebra Developer Community

Intent | Android Developers

Intents and Intent Filters | Android Developers

Android Intents | Tutorial

Workflow Input

Workflow Input Programmer's Guide