Skip to content

Commit

Permalink
fix(android): fixed breaking change to handleOnActivityResult (#3888)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlpoole authored Dec 1, 2020
1 parent b883af4 commit 5fd60e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 5fd60e6

Please sign in to comment.