Skip to content

Commit

Permalink
fix(android): save activity result launcher calls (#5004)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Sep 3, 2021
1 parent 8a08579 commit 2c1eb60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,10 @@ PluginCall getPluginCallForLastActivity() {
return pluginCallForLastActivity;
}

void setPluginCallForLastActivity(PluginCall pluginCallForLastActivity) {
this.pluginCallForLastActivity = pluginCallForLastActivity;
}

/**
* Release a retained call
* @param call a call to release
Expand Down
4 changes: 2 additions & 2 deletions android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void startActivityForResult(PluginCall call, Intent intent, String callba
// return when null since call was rejected in getLauncherOrReject
return;
}

bridge.setPluginCallForLastActivity(call);
lastPluginCallId = call.getCallbackId();
bridge.saveCall(call);
activityResultLauncher.launch(intent);
Expand Down Expand Up @@ -894,7 +894,7 @@ protected void handleRequestPermissionsResult(int requestCode, String[] permissi
* @return a new {@link Bundle} with fields set from the options of the last saved {@link PluginCall}
*/
protected Bundle saveInstanceState() {
PluginCall savedCall = getSavedCall();
PluginCall savedCall = bridge.getSavedCall(lastPluginCallId);

if (savedCall == null) {
return null;
Expand Down

0 comments on commit 2c1eb60

Please sign in to comment.