Listen for 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 GriverTitleBarCloseClickEvent
Implement the GriverTitleBarCloseClickEvent interface and write your business logic in the onCloseClick
method. Refer to the following sample on how to implement the interface.
public class DemoGriverTitleBarCloseClickEvent implements GriverTitleBarCloseClickEvent {
@Override
public void onCloseClick() {
}
@Override
public void onInitialized() {
}
@Override
public void onFinalized() {
}
}
For details about the interface, see GriverTitleBarCloseClickEvent .
Step 2: Register close click events
Refer to the following sample code to call the registerEventHandler API to register the close click event after initializing the SDK:
Griver.registerEventHandler(new GriverEventManifest(DemoGriverTitleBarCloseClickEvent.class.getName(), Arrays.asList(GriverTitleBarCloseClickEvent.class.getName()), App.class));
For more information about the above API, refer to registerEventHandler.
Interface
GriverTitleBarCloseClickEvent
The definition of the GriverTitleBarClickEvent interface is shown in the following code:
public interface GriverTitleBarCloseClickEvent extends GriverEvent {
void onCloseClick();
}
Method
Method Name | Description |
onCloseClick | The listening event is called when the titlebar's close button is clicked. |