diff --git a/README.md b/README.md index ca18e627b..4de7b7377 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ instance, or the system browser. - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). - __useWideViewPort__: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is `no`, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is `yes` and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to `yes`). - __fullscreen__: Sets whether the InappBrowser WebView is displayed fullscreen or not. In fullscreen mode, the status bar is hidden. Default value is `yes`. + - __launchInNewTask__: When using target `_system`, sets to `yes` to launch system's browser in a new task. Default value is `no`. iOS supports these additional options: diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index eed595016..316810b5b 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -118,6 +118,7 @@ public class InAppBrowser extends CordovaPlugin { private static final String FOOTER_COLOR = "footercolor"; private static final String BEFORELOAD = "beforeload"; private static final String FULLSCREEN = "fullscreen"; + private static final String LAUNCH_NEW_TASK = "launchInNewTask"; private static final int TOOLBAR_HEIGHT = 48; @@ -149,6 +150,7 @@ public class InAppBrowser extends CordovaPlugin { private String footerColor = ""; private String beforeload = ""; private boolean fullscreen = true; + private boolean launchInNewTask = false; private String[] allowedSchemes; private InAppBrowserClient currentClient; @@ -241,7 +243,7 @@ else if (url.startsWith(WebView.SCHEME_TEL)) // SYSTEM else if (SYSTEM.equals(target)) { LOG.d(LOG_TAG, "in system"); - result = openExternal(url); + result = openExternal(url, features); } // BLANK - or anything else else { @@ -455,7 +457,7 @@ private HashMap parseFeature(String optString) { * @param url the url to load. * @return "" if ok, or error message. */ - public String openExternal(String url) { + public String openExternal(String url, HashMap features) { try { Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); @@ -468,6 +470,17 @@ public String openExternal(String url) { intent.setData(uri); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName()); + + if (features != null) { + String launchNewTask = features.get(LAUNCH_NEW_TASK); + if (launchNewTask != null) { + launchInNewTask = launchNewTask.equals("yes") ? true : false; + } + } + + if (launchInNewTask) { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + } // CB-10795: Avoid circular loops by preventing it from opening in the current app this.openExternalExcludeCurrentApp(intent); return "";