简体   繁体   中英

How to force open of a new browser in Android (from a webpage)?

I have an application that reads a webpage.

The problem is that my application buit-in browser can't read the content correctly. But if I open the link with the chrome of firefox application it works fine in the mobile.

I have control only over the webpage. So I would like to to know:

  • It's possible to a web page to make the mobile application open the browser selector like Firefox, Chrome (like target="_blank" in html champ).

  • There is any web tool to process the javascript online and render a simpler view to my mobile browser?

You can add the following code to your webview:

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

For more info, check here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM