---
page_source: https://docs.hdfcbank.juspay.in/docs/hypercheckout-mobile-sdk/flutter/how-to-integrate-sdks/handle-sdk-lifecycle-events
page_title: Handle SDK Lifecycle Events
---


# Handle SDK Lifecycle Events



The Hypercheckout SDK runs in a fragment. Hence, to handle certain events based upon activity life cycle, client will need to forward those events to the Hypercheckout SDK.

These events are crucial for seamless functioning of features like OTP reading, App Switches (UPI Intent), Hardware backpress.

Following are the lifecycle events which SDK needs:


### Step 1 onBackPressed


In order to handle hardware backpress done by user, you have to call `onBackPressed()` on HyperServices Instance in the onBackPressed function of your Checkout Activity.

onBackPressed function returns a boolean. When this return value is true hardware backpressed is consumed by frontend SDK, if its false you need to handle backpress.



#### Code Snippets: -

#### Flutter Code Snippet:

```flutter
return WillPopScope(
      onWillPop: () async {
        if (Platform.isAndroid) {
          var backpressResult = await widget.hyperSDK.onBackPress();

          if (backpressResult.toLowerCase() == "true") {
            return false;
          } else {
            return true;
          }
        } else {
          return true;
        }
      },
```
