Open link in device's default browser. Crosswalk android application

I am creating an app for Android devices using HTML and JavaScript. I am using Crosswalk (15.44.384.12) to bundle this into an Android application, which pretty much creates an android app with a web browser built in, to run my application.

I have everything working on the Android device, but I am struggling to find out how to open a link from my app in the device’s default browser using JavaScript.

  • window.openDatabase throws TypeError: Object[object DOMWindow] has no method 'openDatabase' on Android
  • Integrate javascript in android
  • How to Display the Html content page wise using webview in android?
  • Compass/orientation model for Android
  • Set camera width and height phonegap camera
  • want to send hexadecimal string data in java
  • If I use window.open(), it will just load within my app, which is not what I want.

    I have tried using window.open(‘http://example.com’, ‘_blank’), I have also tried ‘_system’, to no avail.

  • Access UI from JavaScript on Android
  • Modify alert() title (Javascript in Android Webview)
  • android 2.x - 4.3.x phonegap doesn't support flexbox css3
  • Why can't my Android device play HTML5 video loaded as Blob via XHR?
  • Webview with JavaScript interface
  • How to get mime type in Cordova getPicture
  • One Solution collect form web for “Open link in device's default browser. Crosswalk android application”

    Same here. All hrefs and window.open calls are opened in the WebView.

    We can use a workaround that was also possible in Cordova: to intercept URLs in native Java code.

    First create a custom XWalkResourceClient to intercept your urls depending on your needs:

    XWalkResourceClient myResourceClient = new XWalkResourceClient(xWalkWebView){
        ...
    
        @Override
        public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
                if(url.contains("whatever")){
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    startActivity(i);
    
                    return true;
                }
    
                return super.shouldOverrideUrlLoading(view, url);
        }
    };
    

    and then in your activity, you can set that client to the XWalk view:

    myXWalkWebView.setResourceClient(myResourceClient);