Skip to content

Commit

Permalink
fix(android): calls re-saved during permission/activity result callba…
Browse files Browse the repository at this point in the history
…cks were being released
  • Loading branch information
carlpoole authored Mar 4, 2021
1 parent e433691 commit 502a2d1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ private void triggerPermissionCallback(Method method, Map<String, Boolean> permi

// validate permissions and invoke the permission result callback
if (bridge.validatePermissions(this, savedCall, permissionResultMap)) {
if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}

try {
method.setAccessible(true);
method.invoke(this, savedCall);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}

if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}
}
}

Expand All @@ -159,17 +159,17 @@ private void triggerActivityCallback(Method method, ActivityResult result) {
savedCall = bridge.getPluginCallForLastActivity();
}

if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}

// invoke the activity result callback
try {
method.setAccessible(true);
method.invoke(this, savedCall, result);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}

if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}
}

/**
Expand Down

0 comments on commit 502a2d1

Please sign in to comment.