Capture data using Zebra Android devices
Learn how to capture data with Zebra Android devices using DataWedge APIs.
Zebra Technologies specializes in integrated mobile devices for large-scale industry deployments, such as warehouse and inventory management, field operations, and logistics. You can build Retool Mobile apps for Zebra Android devices that interact with dedicated Zebra hardware, such as scanners and sensors.
Retool uses the Zebra DataWedge APIs to receive and capture events using the Zebra DataWedge Reader component. To see an example app using the Zebra APIs, try out the Inventory Management with Zebra Scanner template.
Prerequisites
For security purposes, Zebra controls access to the DataWedge Intents APIs. Zebra administrators must first create a Zebra DataWedge profile. You can create this profile on the Zebra DataWedge setup screen within the Settings menu. Open the top left menu when viewing the Retool Mobile app on a Zebra device and select Settings > Zebra DataWedge setup to get started.
This screen contains information for debugging your DataWedge profile, as well as a button to automatically configure a profile for Retool and an output of events:
Alternatively, administrators can create a Zebra DataWedge profile with the following configuration to add the Retool Mobile app as an approved DataWedge application.
Setting | Value |
---|---|
Associated app | com.retool.retool |
Activity | * |
Intent output | Enabled |
Intent action | com.retool.zebra.ACTION |
Intent category | Clear or leave unset |
Intent delivery | Broadcast intent |
Once configured, the Retool Mobile app is able to receive captured data and provide it to your mobile apps. Refer to the Zebra DataWedge APIs documentation for more information on approved apps and profiles.
Receive captured data in Retool Mobile
The Zebra DataWedge Reader component allows your Retool Mobile apps to receive this data and use it elsewhere. Add this component to your mobile app to receive captured Zebra data and configure event handlers to perform actions with it.
When a Zebra device captures data, it sends it as a DataWedge Intent object. The Zebra DataWedge Reader component functions as a listener and receives the Intent, which triggers the Capture event. The component's data
property is set to the received Intent.
The intent object contains a com.symbol.datawedge.data_string
key that represents the data in the scanned barcode, and a com.symbol.datawedge.label_type
key that represents the barcode type. Review Zebra's documentation on the intent object to see all possible values for label_type
. The intent object also contains various other keys depending on the model of your Zebra device. See below for a sample intent object:
{
"com.symbol.datawedge.decoded_mode": "single_decode",
"v2API": true,
"com.motorolasolutions.emdk.datawedge.label_type": "LABEL-TYPE-CODE128",
"com.symbol.datawedge.data_string": "1234567890",
"com.symbol.datawedge.data_dispatch_time": 1701754038282,
"com.motorolasolutions.emdk.datawedge.data_string": "1234567890",
"com.motorolasolutions.emdk.datawedge.source": "scanner",
"com.symbol.datawedge.label_type": "LABEL-TYPE-CODE128",
"com.symbol.datawedge.source": "scanner"
}
You configure event handlers to trigger queries or perform actions when events occur. Click + Add in the Interaction section of the Inspector to add an event handler.
For example, you can use the Run script action to set the value of a Mobile Text component using JavaScript. This is useful when testing your apps on Zebra devices. This example wraps the data
property in JSON.stringify()
to display it as a string.
text1.setValue(JSON.stringify(zebraDataWedgeReader1.data));
If you want to extract data from the barcode, access the com.symbol.datawedge.data_string
key on the data object. For example: zebraDataWedgeReader1.data['com.symbol.datawedge.data_string']
.
Hide the Zebra component button
The Zebra DataWedge Reader component initially displays a Toggle scan button that can trigger the embedded capture hardware, such as a scanner. If your Zebra devices already have a dedicated hardware button, you can hide the component. In the Layout section of the Inspector, set the component's Hidden setting to true
.
Your mobile app only needs to contain a Zebra DataWedge Reader component to receive captured data, but it doesn't need to be visible.