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

fix(android): fixed breaking change to handleOnActivityResult #3888

Merged
merged 1 commit into from
Dec 1, 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
8 changes: 7 additions & 1 deletion android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,13 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
plugin.getInstance().saveCall(pluginCallForLastActivity);
}

plugin.getInstance().handleOnActivityResult(pluginCallForLastActivity, requestCode, resultCode, data);
CapacitorPlugin pluginAnnotation = plugin.getPluginClass().getAnnotation(CapacitorPlugin.class);
if (pluginAnnotation != null) {
// Use new callback with new @CapacitorPlugin plugins
plugin.getInstance().handleOnActivityResult(pluginCallForLastActivity, requestCode, resultCode, data);
} else {
plugin.getInstance().handleOnActivityResult(requestCode, resultCode, data);
}

// Clear the plugin call we may have re-hydrated on app launch
pluginCallForLastActivity = null;
Expand Down
12 changes: 12 additions & 0 deletions android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,18 @@ protected void restoreState(Bundle state) {}
*/
protected void handleOnActivityResult(PluginCall lastPluginCall, int requestCode, int resultCode, Intent data) {}

/**
* Handle activity result, should be overridden by each plugin
* @deprecated use {@link #handleOnActivityResult(PluginCall, int, int, Intent)} in
* conjunction with @CapacitorPlugin
*
* @param requestCode
* @param resultCode
* @param data
*/
@Deprecated
protected void handleOnActivityResult(int requestCode, int resultCode, Intent data) {}

/**
* Handle onNewIntent
* @param intent
Expand Down