Skip to content

Commit

Permalink
feat(android): Handle onDestroy lifecycle event in plugins (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebras authored Feb 7, 2020
1 parent dfc1ed6 commit 6fe6d25
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void onStop() {
@Override
public void onDestroy() {
super.onDestroy();
this.bridge.onDestroy();
if (this.mockWebView != null) {
mockWebView.handleDestroy();
}
Expand Down
5 changes: 5 additions & 0 deletions android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ protected void handleOnPause() {}
*/
protected void handleOnStop() {}

/**
* Handle onDestroy
*/
protected void handleOnDestroy() {}

/**
* Start a new Activity.
*
Expand Down

0 comments on commit 6fe6d25

Please sign in to comment.