Listen for the close click events
The close click events are triggered when the user clicks the close button to close pop-ups, menus, etc in the mini program. By listening for the close click events, the super app captures the user's action of clicking the close button and then performs the specified operations. This topic introduces how to listen for the mini program close click events by integrating the SDK.
Procedures
To listen for the mini program close click events, complete the following steps:
Step 1: Implement the GriverTitleBarCloseClickEvent interface
Implement the GriverTitleBarCloseClickEvent interface and write your business logic in the onCloseClick
method. Refer to the following sample on how to implement the interface.
class DemoGriverTitleBarCloseClickEvent : GriverTitleBarCloseClickEvent {
override fun onCloseClick() {
}
override fun onInitialized() {
}
override fun onFinalized() {
}
}
Step 2: Register the DemoGriverTitleBarCloseClickEvent class
Refer to the following sample code to call the registerEventHandler API to register the close click event after initializing the SDK.
Griver.registerEventHandler(
GriverEventManifest(DemoGriverTitleBarCloseClickEvent::class.java.getName(), java.util.Arrays.asList<kotlin.String?>(
GriverTitleBarCloseClickEvent::class.java.getName()), App::class.java))
Structures
GriverTitleBarCloseClickEvent interface
The definition of the GriverTitleBarClickEvent interface is shown in the following code:
interface GriverTitleBarCloseClickEvent : GriverEvent {
fun onCloseClick()
}
Based on the definition, this interface provides the following methods:
Method Name | Description |
onCloseClick | The listening event is called when the titlebar's close button is clicked. |