Search code examples
androidandroid-studiowebviewandroid-webview

How to use external browser on web view Android app


I convert WordPress website to android app, in my website lots of external links i need to open external links browser like telegram, in telegram all external links open in external browser in the app


Solution

  • Problem SOlved guys thanks for your replays

    Source (from sven)

    webView.setWebViewClient(new WebViewClient(){
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url != null && (url.startsWith("http://") || url.startsWith("https://"))) {
            view.getContext().startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        } else {
            return false;
        }
    }
    

    });