Listen to the back press event

This topic guides you through how to listen for the mini program back press event.

Overview

From IAPConnect 2.34.0, Griver supports the back press event by implementing the GriverBackPressedPointEvent interface. The following sections provide the detailed steps:

Step 1. Implement GriverBackPressedPointEvent

To listen for the mini program back button press event, implement the GriverBackPressedPointEvent interface, and write your business logic in the handleBackPressed function:

copy
public class DemoGriverBackPressedPointEvent implements GriverBackPressedPointEvent {
    
    @Override
    public void handleBackPressed(Page var1) {
    }
    
    @Override
    public void onInitialized() {
        
    }
    
    @Override
    public void onFinalized() {
        
    }
}

Step 2. Register the back press event

Register the back press event during initializing:

copy
    Griver.registerEventHandler(
                new GriverEventManifest(DemoGriverBackPressedPointEvent.class.getName(), Arrays.asList(
                        GriverBackPressedPointEvent.class.getName()), App.class));