onDestroy()
The onDestroy() method is used to destroy the instance and release all associated resources.
Method signature
Java
Kotlin
copy
public void onDestroy()Parameters
This method takes no input parameters.
Return value
This method does not return any value.
Usage scenarios
Manual call
In the following cases, call this method to release SDK component resources:
- When the buyer leaves the checkout page or switches views, release the component resources created by the createPaymentSession (One-time Payments) or createVaultingSession API.
- When the buyer initiates multiple payments or card binding attempts and the parameters in the
AMSBaseConfigurationchanges, release the component resources created by the createPaymentSession (One-time Payments) or createVaultingSession API.
Automatic release
In the following cases, the SDK automatically releases resources:
- When the buyer initiates multiple payments or card binding attempts and the parameters in
AMSBaseConfigurationhave not changed, the SDK will automatically recycle some resources after payment or card binding completion to reset to the state beforecreateComponent().