Mimicking Field-Level Profiles with the DataWedge API
**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 for more information.**
It is possible today to associate a 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 (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:
- : Instructs DataWedge to switch to a specific profile. This can be invoked when the desired text field receives focus
- : Retrieves the current active profile. This can optionally be used to confirm the profile has been applied successfully.
The application registers an onFocus() listener for each of the text fields and sends a Intent to DataWedge. The UI is updated with the current profile in response to a 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, .
- 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.
- 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 API
- The and APIs were both introduced in DataWedge , this in available on the vast majority of our Android devices but make sure you are running a sufficiently high version of DataWedge.