Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
If your Android app uses the Fragment component, you need to add a code snippet to your app so that you can add visual events by clicking relevant elements on the DTM portal. In this way, the added visual events remain valid when users change the tab display order in your app.
- Fragment fragment = new Fragment();
- Bundle bundle = new Bundle();
- // The value is a non-empty string. When creating a Fragment component, call the setArguments method of Fragment to add the value whose key is DTM_FRAGMENT_TAG to the bundle.
- bundle.putString("DTM_FRAGMENT_TAG","value");
- fragment.setArguments(bundle);
If you have integrated the DTM plugin, skip this step. For details, please refer to (Optional) Integrating the DTM Plugin.
- @Override
- public void onResume() {
- super.onResume();
- if (getView() != null && getArguments() != null) {
- // The value is a non-empty string set in Step 1.
- String value = getArguments().getString("DTM_FRAGMENT_TAG");
- // The key in getView().setTag has a fixed value of 0xffff0000, which cannot be modified.
- getView().setTag(0xffff0000,value);
- }
- }
To ensure visual event accuracy, ensure that the value is unique in the Fragment instance.



There are three visual event types: Current position, Similar element, and Same text.
Here, the Similar element option is used as an example.

The added visual event will be displayed under Element visual events (available) on the right page. Components added as visual event parameters will be marked with blue boxes. If the visual event component is the same as the component added as the visual event parameter, the component will be marked with a green box.

If you set the trigger condition to a visual event for a tag, parameters of the visual event will be added to the custom parameter list of the tag (if the tag supports custom parameters), and you can manually modify the parameter references.
DTM allows you to add visual events for web pages in Android apps by tag template.

When accessing a web page containing WebView in your app, you can add a screen visual event for the web page. Only native components can be selected as parameters of this visual event.

When accessing a web page containing WebView in your app, you can select only native components as visual event parameters if you select a native component to add a visual event, and select only WebView components as visual event parameters if you select a WebView component to add a visual event.
There are two visual event types for WebView components: Current position and Similar element.

The added visual event will be displayed under Element visual events (available) on the right page. Components added as visual event parameters will be marked with blue boxes. If the visual event component is the same as the component added as the visual event parameter, the component will be marked with a green box.
