Skip to content

Android View onTouchListener

OnTouchListener not working ?

If your app is not registering touch events once the Contextual SDK has been integrated, it may be because the OntouchListener is not working. As Android only allows one OnTouchListener, please follow the steps below to ensure the apps native OntouchListener and the Contextual OntouchListener are working properly.

1
2
3
4
5
//Get the instance of our SDK :

CtxCompositeOnClickListener.addOnClickListener(OnTouchListener { v, event ->
   // Your code here.
}, yourView);

Enable/Disable Contextual OnTouchListener

You can also enable or disable Contextual OnTouchListener. In the following function by passing true it will enable/re-enable the Contextual OnTouchListener, and a false value will completely disable the feature.

1
2
3
4
 CtxCompositeOnClickListener.enableCtxOnTouchListener(
     activity,
     <Boolean>
 );

Explanation

Contextual uses the OnTouchListener to capture events in your app. These events - including page views or touch events - can then be used in experiments as filters. For example, to target users the third time they enter a view, the OnTouchListener would be required to capture the number of times a user has entered a screen view before that time.


Last update: 2024-01-22