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