diff --git a/android/capacitor/src/main/java/com/getcapacitor/MessageHandler.java b/android/capacitor/src/main/java/com/getcapacitor/MessageHandler.java index 8b83e1236b..bca7f5337e 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/MessageHandler.java +++ b/android/capacitor/src/main/java/com/getcapacitor/MessageHandler.java @@ -109,6 +109,9 @@ public void sendResponseMessage(PluginCall call, PluginResult successResult, Plu } catch (Exception ex) { Logger.error("sendResponseMessage: error: " + ex); } + if (!call.isKeptAlive()) { + call.release(bridge); + } } private void callPluginMethod(String callbackId, String pluginId, String methodName, JSObject methodData) { diff --git a/android/capacitor/src/main/java/com/getcapacitor/Plugin.java b/android/capacitor/src/main/java/com/getcapacitor/Plugin.java index 546841f2fb..dc4662ddce 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Plugin.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Plugin.java @@ -140,10 +140,6 @@ private void triggerPermissionCallback(Method method, Map 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); @@ -158,11 +154,6 @@ private void triggerActivityCallback(Method method, ActivityResult result) { if (savedCall == null) { savedCall = bridge.getPluginCallForLastActivity(); } - - if (!savedCall.isKeptAlive()) { - savedCall.release(bridge); - } - // invoke the activity result callback try { method.setAccessible(true);