【发布时间】:2017-08-22 16:51:21
【问题描述】:
我在尝试覆盖 URL 时遇到问题 我在我的 webviewclient 中使用了这段代码
mywebview.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().contains("google") || Uri.parse(url).getHost().contains("goo.gl") ) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));
startActivity(intent);
finish();
return true ;
}
});
然后包含上述字符串的链接在 webview 本身中打开,但其他链接(如 facebook)都无法在任何外部浏览器中打开,而 Youtube 链接正在 Youtube 应用程序中打开。 以及如何在 facebook 应用程序中打开 facebook 链接或在本地应用程序中打开市场链接。
【问题讨论】:
标签: android webview android-webview