Mimicking Field-Level Profiles with the DataWedge API

Darryn Campbell -
3 MIN READ
136

**This post came about after a conversation at our EMEA AppForum during the “DataWedge Intent API session”.  The AppForum series for 2019 is well underway Register now for  Sydney, Beijing in August and Las Vegas in October – see the events page for more information.**

It is possible today to associate a DataWedge Profile with an Android application and an activity within that application.  The Windows Mobile / Windows CE implementation of DataWedge allowed association with an application and a ‘Window title’ so it was possible to specify a separate profile for any Window (capital ‘W’) within that app including, text boxes, text areas etc.

This has led to several Android developers requesting the ability to automatically switch profiles based on the selected text field, like how DataWedge used to work on Windows Mobile / CE.  This is ‘on the backlog’ & may be added in the future but developers are already able to achieve this today using the DataWedge Intent API.

With the following APIs an Android application can switch between profiles dynamically depending on which text field has focus:

  • SWITCH_TO_PROFILE: Instructs DataWedge to switch to a specific profile.  This can be invoked when the desired text field receives focus
  • GET_ACTIVE_PROFILE: Retrieves the current active profile.  This can optionally be used to confirm the profile has been applied successfully.

I have created a test app which shows how this could be achieved with a native Kotlin application but since the DataWedge API is Intent-based, the principle could be easily extended to any type of application, Java, Xamarin or JavaScript (via Enterprise Browser): https://github.com/darryncampbell/DataWedgeFieldBasedProfiles.  As with any of my proof of concept applications, this app is provided without any guarantee or warranty from Zebra.

The application registers an onFocus() listener for each of the text fields and sends a SWITCH_TO_PROFILE Intent to DataWedge.  The UI is updated with the current profile in response to a GET_ACTIVE_PROFILE request, though this second step is optional and just provided so the application gives some feedback.  Dummy profiles are created as part of the onCreate() call, again using a DataWedge API, CREATE_PROFILE.

Use Cases:

  • Selecting different symbologies or scanner settings (e.g. picklist mode) in specific fields
  • Disabling the scanner in certain fields
  • Porting an application from WM/CE, retaining the existing logic but just rewriting the application code.

Considerations:

  • This technique requires modifying the application, there may be better ways to achieve your desired behaviour for example with the second use case above the scanner can be disabled directly with the SCANNER_INPUT_PLUGIN API
  • The SWITCH_TO_PROFILE and GET_ACTIVE_PROFILE APIs were both introduced in DataWedge 6.2, this in available on the vast majority of our Android devices but make sure you are running a sufficiently high version of DataWedge.

 

profile

Darryn Campbell

Please Register or Login to post a reply

Replies