Overlay Touch Listener
Touches in ordinary Activity and Dialog windows are recorded automatically. If you use a custom View.OnTouchListener on a Popup or Application Overlay, register it through Coryn.setRootOnTouchListener(). This also applies to child Views.
Pass the affected View directly, and use Coryn APIs for every listener replacement or removal after initialisation. Register existing listeners through Coryn as well; calling Android's setOnTouchListener() directly can interrupt touch recording or your listener.
This is commonly needed for a draggable picture-in-picture overlay or a popup whose root or children have custom touch listeners. Standard Activity/Fragment windows and Composables without such popup/overlay listeners need no additional integration.
Setting an Overlay Root Touch Listener
- Lambda
- Listener instance
Coryn.setRootOnTouchListener(
view = overlayRootView,
onTouchListener = { view, event ->
// Handle touch event, then return whether your listener consumed it.
false
}
)
For Kotlin callers, import the extension function and use it on the View:
import ai.coryn.replay.api.core.main.Coryn.corynSetRootOnTouchListener
overlayRootView.corynSetRootOnTouchListener { view, event ->
// Handle touch event, then return whether your listener consumed it.
false
}
val touchListener: View.OnTouchListener = ...
Coryn.setRootOnTouchListener(
view = overlayRootView,
onTouchListener = touchListener
)
Or with the extension function:
val touchListener: View.OnTouchListener = ...
overlayRootView.corynSetRootOnTouchListener(touchListener)
Removing an Overlay Root Touch Listener
When the root no longer needs your custom listener, remove it through Coryn so SDK touch recording remains connected:
Coryn.removeRootOnTouchListener(overlayRootView)
Or with the extension function:
import ai.coryn.replay.api.core.main.Coryn.corynRemoveRootOnTouchListener
overlayRootView.corynRemoveRootOnTouchListener()
Return true only if your listener consumes the event; otherwise return false so normal Android dispatch continues. Do not call view.onTouchEvent() yourself to forward it.