From f99ebe4fdaf8027026e5ed7316e6ebee79ad65c2 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 10 Mar 2021 16:34:15 +0100 Subject: [PATCH] fix(android): Release the call after reject/resolve --- .../src/main/java/com/getcapacitor/MessageHandler.java | 3 +++ .../capacitor/src/main/java/com/getcapacitor/Plugin.java | 9 --------- 2 files changed, 3 insertions(+), 9 deletions(-) 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);