Using DataWedge with Multiple Android Activities

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.

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


Darryn Campbell

Hi Eric,

DataWedge is not a separate download through the Play Store, it is updated by upgrading the device BSP.  You can download TC20 system images from https://www.zebra.com/us/en/support-downloads/software/operating-system/tc20-operating-system.html.  If you look in the release notes for the latest Nougat release (https://www.zebra.com/content/dam/zebra_new_ia/en-us/software/operating-system/tc20-operating-system/TC2X-0414300NG00M1-P13-release-notes.pdf) that includes DataWedge 7.3.  You can also update your device to Oreo which would also give you DataWedge 7.3


Eric Swensson

hi Darryn,

i will try a new image, but from what you are saying, it will only get me DataWedge 7.3 , correct? I saw the spec for 7.6, and i would like the 'scan on presentation' feature.

i would eventually like to use the TC20 to capture barcodes on presentation (the device just sits in a tethered cradle), and have the data transfer over USB cable to a workstation running Windows10, that sees the connected TC20 as a keyboard entry device. is that sort of use case supported?


Darryn Campbell

Hi Eric,

I don't know off the top of my head whether the TC20 supports AIMTYPE Presentation even if it did run DataWedge 7.6.  That note about Presentation Mode in DataWedge 7.6 (or is it 7.5) is talking about support for the sensitivity parameter, not presentation mode itself.  Presentation mode needs support in the scan engine and since this is a lower-tier device it would not surprise me if it were not present - the user or integrator guide does not mention presentation mode.

It IS possible to transfer captured barcodes to a Windows PC, the best way to achieve this is by using the IP Wedge feature, https://techdocs.zebra.com/datawedge/7-6/guide/output/ip/