From c8df31fc7f4e4917022d4abe6489e8edaff9c291 Mon Sep 17 00:00:00 2001 From: Hamza Al Omari Date: Wed, 14 Oct 2026 15:23:54 +0200 Subject: [PATCH] fix(android): register ActivityResult launcher against Bridge for Portals compatibility GeolocationPlugin.load() registered its ActivityResult launcher directly against the Activity. Under Ionic Portals the Bridge is built in PortalFragment.onViewCreated() when the host Activity is already STARTED/RESUMED, so AndroidX's registerForActivityResult guard throws IllegalStateException and the plugin fails to load (masked by Capacitor as PluginLoadException). Register against Capacitor's Bridge instead, which resolves to the hosting Fragment (still CREATED) under Portals and to the Activity otherwise. The contract, callback, and runtime behavior are unchanged. --- .../com/capacitorjs/plugins/geolocation/GeolocationPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/kotlin/com/capacitorjs/plugins/geolocation/GeolocationPlugin.kt b/android/src/main/kotlin/com/capacitorjs/plugins/geolocation/GeolocationPlugin.kt index 5928e0c..73ffe40 100644 --- a/android/src/main/kotlin/com/capacitorjs/plugins/geolocation/GeolocationPlugin.kt +++ b/android/src/main/kotlin/com/capacitorjs/plugins/geolocation/GeolocationPlugin.kt @@ -45,7 +45,7 @@ class GeolocationPlugin : Plugin() { super.load() coroutineScope = CoroutineScope(Dispatchers.Main) - val activityLauncher = activity.registerForActivityResult( + val activityLauncher = bridge.registerForActivityResult( ActivityResultContracts.StartIntentSenderForResult() ) { result -> CoroutineScope(Dispatchers.Main).launch {