diff --git a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java index e225110b86..e082ac5c96 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java @@ -846,6 +846,15 @@ public void onStop() { } } + /** + * Handle onDestroy lifecycle event and notify the plugins + */ + public void onDestroy() { + for (PluginHandle plugin : plugins.values()) { + plugin.getInstance().handleOnDestroy(); + } + } + public void onBackPressed() { PluginHandle appHandle = getPlugin("App"); if (appHandle != null) { diff --git a/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java b/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java index 423bcc048a..2df2882eaa 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java +++ b/android/capacitor/src/main/java/com/getcapacitor/BridgeActivity.java @@ -177,6 +177,7 @@ public void onStop() { @Override public void onDestroy() { super.onDestroy(); + this.bridge.onDestroy(); if (this.mockWebView != null) { mockWebView.handleDestroy(); } diff --git a/android/capacitor/src/main/java/com/getcapacitor/Plugin.java b/android/capacitor/src/main/java/com/getcapacitor/Plugin.java index 3caeaed09d..94e325b8e8 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Plugin.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Plugin.java @@ -532,6 +532,11 @@ protected void handleOnPause() {} */ protected void handleOnStop() {} + /** + * Handle onDestroy + */ + protected void handleOnDestroy() {} + /** * Start a new Activity. *