admin管理员组

文章数量:1616435

HTML5 HYBIRD混合APP需要在H5页面中打开第三方网站(例如:百度),android默认不在当前WebView中打开,反而会调用系统或外部浏览器,解决办法是自己重写WebViewClient,覆盖shouldOverrideUrlLoading并让其返回True。

实现代码

mWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// webview自己加载URL,让后通知系统不需要HandleURL
view.loadUrl(url);
return true;
}
});




原因可以从Android源代码中可知,True if the host application wants to leave the current WebView and handle the url itself, otherwise return false。



/** Give the host application a chance to take over the control when a new url is about to be loaded
* in the current WebView. If

本文标签: 浏览器系统androidwebview