Using DataWedge with Multiple Android Activities

Darryn Campbell -
3 MIN READ

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 current profile or that profile's behaviour and it might not always be obvious which option to use:

  1. Mechanism: Profile activity association
  • Description: 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

  • Access by: DataWedge profile configuration

  1. Mechanism: The SWITCH_TO_PROFILE_API
  • Description: Switch to the specified profile, provided that profile is not associated with another app/activity

  • Access by: The DataWedge API

  1. Mechanism: The SWITCH_SCANNER_API (or similar)
  • Description: Make a temporary modification to the current profile, for example changing the scanner or the scanner parameters

  • Access by: The DataWedge API

  1. Mechanism: The SET_CONFIG_API
  • Description: Make a permanent change to the specified profile

  • Access by: 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.

  1. 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.
  2. Associate the appropriate profiles with their corresponding activities
  3. Deploy your application. The scanner configuration will be automatically managed by DataWedge.

Example

This example application hosted in github uses two activities, each associated with a different profile, imaginatively named "First Profile" and "Second Profile".

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

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

DataWedge Profiles

The above image shows two newly created DataWedge profiles, these will each be associated with a different activity within the application

The first profile is associated with the Main activity

DataWedge Profiles
DataWedge Profiles

The above two images show that the first profile is associated with the first activity in the sample application

The second profile is associated with the Second activity

DataWedge Profiles
DataWedge Profiles

The above two images show that the second profile is associated with the second activity in the sample application

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:

Demo app
Demo app

The above two images show the sample application when each of the activities are brought to the foreground. All the sample app does is display the active profile in a text box

Summary

If you want to handle data capture from multiple activities within your application associate each activity with a DataWedge profile and rely on DataWedge to manage the data capture hardware for you. If you need different behaviour in each activity then use multiple DataWedge profiles, each associated with a different activity.

profile

Darryn Campbell

Please register or login to post a reply

2 Replies

E Eric Swensson

i am a little frustrated trying to upgrade Datawedge v6.6xxx on my TC20 (TC200J, android v7.1.2) to Datawedge version 7.6 , so that i can use some of the new features described in the Zebra docs. I have tried searching through google, the Google App Store, the Zebra support portal, etc and am drawing blanks. Totally baffled ... could you point me down the right path please?
regards, Eric Swensson

S Sean Kennedy

Updates of Versions of Datawedge are part of the LifeGuard suite of updates for devices with a Support Contract.
These Recovery Mode Images are typically found on the Respective Device Support portal ( Googling "TC20 Support" will lead to : https://www.zebra.com/us/en/support-downloads/mobile-computers/handheld… as an example )
Within these support portals are the Platform Specific (GMS or Non-GMS) firmware images and LifeGuard updates.
Known as "CFE" or "Continous Fixes from Engineering" the Lifeguard images and the respective release notes will indicate the Versions of Zebra Software supports (Like Datawedge) to understand where/which to get the updates you seek.