Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

A sample application to show how to use DataWedge with multiple activities

License

Notifications You must be signed in to change notification settings

darryncampbell/DataWedge-Multiple-Activity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please be aware that this application / sample is provided as-is for demonstration purposes without any guarantee of support

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 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.

  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.
  1. Associate the appropriate profiles with their corresponding activities
  2. 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".

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 first profile is associated with the Main activity

DataWedge Profiles DataWedge Profiles

The second profile is associated with the Second activity

DataWedge Profiles DataWedge Profiles

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

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

About

A sample application to show how to use DataWedge with multiple activities

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages