From 74fe051ed9e852293550f201337d427e21c06421 Mon Sep 17 00:00:00 2001 From: Marta Carlos <101343976+OS-martacarlos@users.noreply.github.com> Date: Wed, 18 Dec 2024 10:58:05 +0000 Subject: [PATCH] fix(browser): crash when trying to open blob urls on android (#2274) --- .../plugins/browser/BrowserPlugin.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/browser/android/src/main/java/com/capacitorjs/plugins/browser/BrowserPlugin.java b/browser/android/src/main/java/com/capacitorjs/plugins/browser/BrowserPlugin.java index 1fbc16852..5cb859402 100644 --- a/browser/android/src/main/java/com/capacitorjs/plugins/browser/BrowserPlugin.java +++ b/browser/android/src/main/java/com/capacitorjs/plugins/browser/BrowserPlugin.java @@ -60,25 +60,25 @@ public void open(PluginCall call) { } // open the browser and finish - try { - Intent intent = new Intent(getContext(), BrowserControllerActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - getContext().startActivity(intent); - Integer finalToolbarColor = toolbarColor; - setBrowserControllerListener( - activity -> { + Intent intent = new Intent(getContext(), BrowserControllerActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + getContext().startActivity(intent); + + Integer finalToolbarColor = toolbarColor; + setBrowserControllerListener( + activity -> { + try { activity.open(implementation, url, finalToolbarColor); browserControllerActivityInstance = activity; call.resolve(); + } catch (ActivityNotFoundException ex) { + Logger.error(getLogTag(), ex.getLocalizedMessage(), null); + call.reject("Unable to display URL"); } - ); - } catch (ActivityNotFoundException ex) { - Logger.error(getLogTag(), ex.getLocalizedMessage(), null); - call.reject("Unable to display URL"); - return; - } + } + ); } @PluginMethod