Skip to content

Commit

Permalink
feat(android): Handle onDestroy lifecycle event in plugins (ionic-tea…
Browse files Browse the repository at this point in the history
  • Loading branch information
jlebras authored and priyankpat committed Feb 13, 2020
1 parent 43851d5 commit a27998c
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 @@ -179,6 +179,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 @@ -534,6 +534,11 @@ protected void handleOnPause() {}
*/
protected void handleOnStop() {}

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

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

0 comments on commit a27998c

Please sign in to comment.