From b66f0f33b8e3f8ad51ea6c0b684a075535cb787b Mon Sep 17 00:00:00 2001 From: Manuel Beck Date: Mon, 20 Apr 2026 18:06:08 +0200 Subject: [PATCH] Call new method `CordovaPlugin.onRequestPermissionsResult` (#1855) - Fixes https://github.com/apache/cordova-android/issues/1388 - `CordovaInterfaceImpl` called the deprecated method `CordovaPlugin.onRequestPermissionResult` but not the new one. Now the one will also be called. - Renamed `CordovaInterfaceImpl.onRequestPermissionResult` to `CordovaInterfaceImpl.onRequestPermissionsResult` to reflect the new method name --- framework/src/org/apache/cordova/CordovaActivity.java | 2 +- framework/src/org/apache/cordova/CordovaInterfaceImpl.java | 6 +++++- .../apache/cordova/unittests/EmbeddedWebViewActivity.java | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 3a046981..83e58bf4 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -577,7 +577,7 @@ public class CordovaActivity extends AppCompatActivity { try { - cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults); + cordovaInterface.onRequestPermissionsResult(requestCode, permissions, grantResults); } catch (JSONException e) { diff --git a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java index 91acfcb4..319f0c81 100644 --- a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -217,11 +217,15 @@ public class CordovaInterfaceImpl implements CordovaInterface { * @param permissions * @param grantResults */ - public void onRequestPermissionResult(int requestCode, String[] permissions, + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException { Pair callback = permissionResultCallbacks.getAndRemoveCallback(requestCode); if(callback != null) { + // This one is deprecated - see https://github.com/apache/cordova-android/issues/592 + // and should be removed in a future release callback.first.onRequestPermissionResult(callback.second, permissions, grantResults); + // Call the new method + callback.first.onRequestPermissionsResult(callback.second, permissions, grantResults); } } diff --git a/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java b/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java index 9dfbc5f9..8a88ae91 100644 --- a/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java +++ b/test/androidx/app/src/main/java/org/apache/cordova/unittests/EmbeddedWebViewActivity.java @@ -87,7 +87,7 @@ public class EmbeddedWebViewActivity extends AppCompatActivity { * Called by the system when the user grants permissions! * * Note: The fragment gets priority over the activity, since the activity doesn't call - * into the parent onRequestPermissionResult, which is why there's no override. + * into the parent onRequestPermissionsResult, which is why there's no override. * * @param requestCode * @param permissions @@ -98,7 +98,7 @@ public class EmbeddedWebViewActivity extends AppCompatActivity { int[] grantResults) { try { - cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults); + cordovaInterface.onRequestPermissionsResult(requestCode, permissions, grantResults); } catch (JSONException e) {