Tutorial: Scan with Datawedge Intent output on Zebra devices

This tutorial will take you through scanning barcode data via Android Intents using DataWedge on Zebra devices

DataWedge configuration

The first step is to configure the DataWedge service with an INPUT (the barcode scanner) and an OUTPUT (send an Intent)

Launch the DataWedge application on the device, there is no need to install anything as it comes pre-installed on all Zebra Android mobile devices.

Select the profile which will be associated with your application, unless you configure a separate profile then DataWedge will use “Profile0 (default)”


  • The profile is enabled
  • Barcode input is enabled
  • Intent output is enabled
  • All other inputs and outputs can be disabled.

Configure the Intent Output as follows (as shown in the screenshot below):

  • Intent action: This is an implicit intent that will be sent by DataWedge, it is up to your application to ensure it is configured to receive this intent.  For the purposes of this tutorial, specify com.dwexample.ACTION.
  • Intent category: The category that is associated with the intent sent by DataWedge following each scan.  Leave this blank for this tutorial.
  • Intent delivery, One of

For the tutorial, your Intent output should match the screenshot below.

The application

Moving over to the application now, there are several key parts to ensure we are able to receive the intent data that DataWedge is sending.

First, we can pre-define some of the strings to make it easier to receive and extract the scanned data.  The intent’s action is defined as “dw_action” and once we receive an intent it will contain extras representing the scanned data for source, type and data as listed in the official docs

    <string name="dw_action">com.dwexample.ACTION</string>
    <string name="datawedge_intent_key_source">
    <string name="datawedge_intent_key_label_type">
    <string name="datawedge_intent_key_data">

Because we configured DataWedge to send a broadcast intent our application must now register a broadcast receiver.

Obviously if we had configured DW to start an activity we could register for that in our manifest and call getIntent() in onCreate() or if we had configured it as start service we could create a service to receive the intent. 

For this example we will register a dynamic broadcast receiver in the onCreate() call of our application.  If you were doing this in a production application you would more likely register / unregister in the onResume() / onPause().

Note that the action we are filtering on matches the action that we configured the DataWedge service to send.

protected void onCreate(Bundle savedInstanceState) {
    IntentFilter filter = new IntentFilter();
    registerReceiver(myBroadcastReceiver, filter);

Having registered a broadcast receiver we had better define one.  You could do this in a separate class but for this tutorial you can just define a receiver within your MainActivity.java

private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(getResources().
          getString(R.string.dw_action))) {

The logic of extracting the scanned data and displaying it on the screen is handled by its own method.  Note that the extra keys were defined earlier in the strings.xml file.  The below code assumes a UI exists in which to place the data but a production application will be driving a lot of its behaviour following a scan.

private void displayScanResult(Intent initiatingIntent)
    String decodedSource = initiatingIntent.getStringExtra(
    String decodedData = initiatingIntent.getStringExtra(
    String decodedLabelType = initiatingIntent.getStringExtra(

    final TextView lblScanSource = (TextView) 
    final TextView lblScanData = (TextView) 
    final TextView lblScanLabelType = (TextView) 

Those are all of the key points to receive scanned data via intent, the flexibility of both Android and DataWedge allow for many other possible configurations for receiving data but the above should be a good jumping off point.

There is a sample application that accompanies this blog and shows all the code at https://github.com/darryncampbell/DataWedge-Intent-Example-1

Next Steps

For a better understanding of DataWedge concepts such as Profiles, different input plugins e.g. SimulScan and different decode modes such as UDI then please consult the DataWedge documentation.  There is also an unrelated Intent API exposed by DataWedge.

For a better understanding of Android Intents and Intent filters, please consult the Android documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *