Please be aware that this application / sample is provided as-is for demonstration purposes without any guarantee of support
This article assumes familiarity with Zebra's DataWedge tool as well as the DataWedge profile mechanism. For an overview of DataWedge, please refer to the DataWedge Techdocs page
A very common use case for many Zebra Android developers is using the device scanner across multiple activities in their application, this could cover the following:
- Scanning barcodes from multiple different activities
- Having different scanner configurations, depending on which activity is in the foreground
DataWedge has a number of ways to control the profile in effect or that profile's behaviour and it might not always be obvious which option to use:
Mechanism | Description | Access by |
---|---|---|
Profile activity association | Each profile can be (optionally) mapped to an application or an activity within that application. When that activity comes to the foreground, the associated profile is applied | DataWedge profile configuration |
The SWITCH_TO_PROFILE_API | Switch to the specified profile, provided that profile is not associated with another app/activity | The DataWedge API |
The SWITCH_SCANNER_API (or similar) | Make a temporary modification to the current profile, for example changing the scanner or the scanner parameters. | The DataWedge API |
The SET_CONFIG_API | Make a permanent change to the specified profile | The DataWedge API |
Although any of the above mechanisms could technically work, the "Profile activity association" technique is the recommended approach for handling scanning across multiple activities.
- Create the DataWedge Profile or Profiles your application requires.
- If you need different activities to have different data capture behaviour, for example to recognize different symbologies, then create multiple profiles.
- If your application will only have a single data capture configuration across multiple activities then a single profile will suffice.
- Profiles can be created through the DataWedge application on the device, through the CREATE_PROFILE API or mass deployed.
- Associate the appropriate profiles with their corresponding activities
- Deploy your application. The scanner configuration will be automatically managed by DataWedge.
This example application hosted in github uses two activities, each associated with a different profile, imaginatively named "First Profile" and "Second Profile".
The DataWedge profiles are not automatically created for you, to use this app, first install it then create two profiles and associate them with the demo app as shown below:
Two profiles, one for each activity
The first profile is associated with the Main activity
The second profile is associated with the Second activity
The sample app itself will display the active profile in a text box at the top of the screen. Notice the active profile changes depending on which activity is displayed:
Be aware this demo does not process scanned data but merely shows the active profile. To see how to scan data refer to one of the existing samples, e.g. Basic Intent