Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): Handle onDestroy lifecycle event in plugins #2421

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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