You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Android Plugin class has some android activity lifecycle methods which can be overwritten like handleOnResume, handleOnPause, etc...
Would it be possible to add a method handleOnDestroy to the Plugin which is called when the bridge activity's onDestroy is called ?
My use case is the need to clean up things when the app is killed (like programatically generated windows which persist even when the app is killed by the user...).
I'm aware that in some cases the onDestroy activity's method may not be called but I think it doesn't hurt to add it to the plugin Api.
Platform Support Requested
Android
iOS
Electron
Web
Related Code
For the meantime I edited the capacitor code to handle this (in the node_modules...).
Because those are simple modifications , I'm writting them here.
BridgeActivity.java
@Override
public void onDestroy() {
super.onDestroy();
this.bridge.onDestroy();
if (this.mockWebView != null) {
mockWebView.handleDestroy();
}
Log.d(LogUtils.getCoreTag(), "App destroyed");
}
Bridge.java
/**
* Handle onDestroy lifecycle event and notify the plugins
*/
public void onDestroy() {
for (PluginHandle plugin : plugins.values()) {
plugin.getInstance().handleOnDestroy();
}
}
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Add handleOnDestroy for an Android plugin
Describe the Feature Request
The Android Plugin class has some android activity lifecycle methods which can be overwritten like handleOnResume, handleOnPause, etc...
Would it be possible to add a method handleOnDestroy to the Plugin which is called when the bridge activity's onDestroy is called ?
My use case is the need to clean up things when the app is killed (like programatically generated windows which persist even when the app is killed by the user...).
I'm aware that in some cases the onDestroy activity's method may not be called but I think it doesn't hurt to add it to the plugin Api.
Platform Support Requested
Related Code
For the meantime I edited the capacitor code to handle this (in the node_modules...).
Because those are simple modifications , I'm writting them here.
BridgeActivity.java
Bridge.java
Plugin.java
The text was updated successfully, but these errors were encountered: