---
page_source: https://juspay.io/sea/docs/express-checkout-sdk-global/react-native/resources/multiactivity-integration
page_title: Multi-activity Integration
---


# Multi-activity Integration




## Android



It is suggested to maintain a time of 5 seconds or above in between initiate and process. Occasionally this may not be possible within the same Activity. This brings up the use case to call initiate and process from different activities. The SDK takes an Activity and viewGroup as input in the constructor of HyperServices. This activity and view group is used for any UI / context requiring functionality in the SDK. To integrate the SDK across multiple activities the activity and view group must be updated in SDK API. All SDK APIs support overriding the activity and view group.

> **Warning**
> ViewGroup and activity passed to the process API is not specific to that process, but modifies the viewGroup for all future process calls.




#### Modify Activity and viewgroup Code Snippet:

```modify activity and viewgroup
// If you require the sdk to take up the entire screen,
// please follow the other tab

hyper.initiate((FragmentActivity)activity, (ViewGroup)view, initiatePayload, hyperPaymentsCallback);

hyper.process((FragmentActivity)activity, (ViewGroup)view, processPayload);
```

#### Modify Activity without viewgroup Code Snippet:

```modify activity without viewgroup
// If you require to specify the view group the sdk uses,
// please follow the other tab

hyper.initiate((FragmentActivity)activity, initiatePayload, hyperPaymentsCallback);

hyper.process((FragmentActivity)activity, processPayload);
```


> **Note**
> While integrating across multiple activities, be sure to pass activity in all SDK apis.




### **Avoiding memory leaks** 



The SDK holds reference to the activity and view group. While using the SDK across multiple activities, the Android system may destroy older activities. If that was the last activity passed to the SDK, this can create a memory leak.In order to avoid memory leaks, developers must ensure to call resetActivity function of the HyperServices object, while switching activities. This will ensure that SDK does not hold onto the activity and viewGroup passed to the SDK.


#### Java Code Snippet:

```java
// Should be called in onDestroy.
// Activity being destroyed must be passed as argument
// SDK will use this to determine, whether the current held activity is the one being destroyed
hyper.resetActivity(activity)
```


> **Error**
> After calling resetActivity, the next process must pass activity as an argument, else this may result in a crash.

