SWITCH_SCANNER
Introduced in DataWedge 6.5.
Used to switch to a specific scanner at runtime, enabling selection of the optimal scanning device for the application, requirement or situation when an app is launched. Scanner must be available to the device at runtime.
Function Prototype
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SWITCH_SCANNER", "<scanner index>");
Parameters
ACTION [String]: "com.symbol.datawedge.api.ACTION"
EXTRA_DATA [String]: "com.symbol.datawedge.api.SWITCH_SCANNER"
EXTRA_DATA [String]: "<scanner index>" - index number of the scanner to use in the active Profile
Use ENUMERATE_SCANNERS to retrieve an index of scanners.
Result Codes
DataWedge will return the following error codes if the app includes the intent extras RECEIVE_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
- NO_ACTIVE_PROFILE -
- PARAMETER_INVALID - Given scanner parameter is invalid
- PLUGIN_DISABLED - Scanner plug-in is disabled
- PROFILE_DISABLED - Profile is disabled
- SCANNER_ALREADY_ENABLED - Scanner is disabled
- SCANNER_DISABLE_FAILED - Scanner is disabled
- SCANNER_NOT_CONNECTED -
Also see the Result Codes guide for more information.
Return Values
Error and debug messages are logged to the Android logging system, which can be viewed and filtered by the logcat command. Use logcat from an ADB shell to view the log messages:
$ adb logcat -s DWAPI
Error messages are logged for invalid actions, missing parameters or other failures.
Example Code
The code below shows how to pass an intent to change to scanner "3" from the current scanner. To verify results of the switch (or if errors are expected), include the intent extras RECEIVE_RESULT
and COMMAND_IDENTIFIER
to get results.
String scannerIndex = “3”;
// create the intent and action
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SWITCH_SCANNER", scannerIndex);
// generate result codes
i.putExtra("RECEIVE_RESULT","true");
i.putExtra("COMMAND_IDENTIFIER","123456789");
// send the intent
this.sendBroadcast(i);
Notes
(none)
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