SWITCH_SCANNER_PARAMS
Used to pass one or more barcode, scanner and/or reader parameters as intent extras, temporarily modifying the settings of the active Profile. It enables dynamic adjustments to scanner settings in response to changing conditions. For example, a developer might choose to enable scanner illumination when low-light conditions are detected. Any settings applied using this API are discarded upon the next Profile switch.
Notes
Pre-conditions and assumptions:
- DataWedge and the corresponding Profile must be enabled.
- Barcode scanning should be enabled in the active Profile.
- If the intent contains an invalid or unsupported scanner parameter or value, result code(s) will be sent.
Function Prototype
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SWITCH_SCANNER_PARAMS", <bundle>);
Parameters
ACTION [String]: "com.symbol.datawedge.api.ACTION"
EXTRA_DATA [String]: "com.symbol.datawedge.api.SWITCH_SCANNER_PARAMS"
EXTRA_DATA [bundle]: "<name, value>" - Accepts scanner parameters as name-value pairs
Result Codes
DataWedge returns the following error codes if the app includes the intent extras SEND_RESULT
and COMMAND_IDENTIFIER
to enable the app to get results using the DataWedge result intent mechanism. See Example, below.
- DATAWEDGE_DISABLED - DataWedge is disabled
- PROFILE_DISABLED - Profile is disabled
- PLUGIN_DISABLED - Scanner plug-in is disabled
- SCANNER_DISABLED - Scanner is disabled
- PARAMETER_INVALID - Given scanner parameter is invalid
- PARAMETER_NOT_SUPPORTED - Given scanner parameter is not supported
- VALUE_INVALID - Given value for a scanner parameter is invalid
- VALUE_NOT_SUPPORTED - Given value for a scanner parameter is not supported
Also see the Result Codes guide for more information.
Example Code
For single scanner use, the code below passes an intent that switches a scanner parameter for the active scanner in the active profile. To verify results of the switch (or if errors are expected), include the intent extras SEND_RESULT
and COMMAND_IDENTIFIER
to get results (also shown).
// create the intent and action
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
Bundle bScannerParams = new Bundle();
bScannerParams.putString("illumination_mode", "off");
bScannerParams.putString("decode_audio_feedback_uri", "Pollux");
i.putExtra("com.symbol.datawedge.api.SWITCH_SCANNER_PARAMS", bScannerParams);
// generate result codes
i.putExtra(“SEND_RESULT”,"true");
i.putExtra("COMMAND_IDENTIFIER", "123456789"); //returned as it is with the result
// send the intent
this.sendBroadcast(i);
// register the broadcast receiver (for result codes)
String command = intent.getStringExtra("COMMAND");
String commandidentifier = intent.getStringExtra("COMMAND_IDENTIFIER");
String result = intent.getStringExtra("RESULT");
Bundle bundle = new Bundle();
String resultInfo = "";
if (intent.hasExtra("RESULT_INFO")) {
bundle = intent.getBundleExtra("RESULT_INFO");
Set<String> keys = bundle.keySet();
for (String key : keys) {
if(key.equalsIgnoreCase("RESULT_CODE")){
resultInfo += key + ": " + Arrays.toString(bundle.getStringArray(key));
}else {
resultInfo += key + ": " + bundle.getString(key) + "\n";
}
}
}
For multiple scanners, it is required for Switch Scanner Params API to include the specific scanner to be used with intent extra scanner_selection_by_identifier
.
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.setPackage("com.symbol.datawedge");
i.putExtra("scanner_selection_by_identifier", "BLUETOOTH_RS6000");
i.putExtra("SEND_RESULT","LAST_RESULT");
Bundle bScannerParams = new Bundle();
bScannerParams.putString("illumination_mode", "off");
i.putExtra("com.symbol.datawedge.api.SWITCH_SCANNER_PARAMS", bScannerParams);
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