gpt4 book ai didi

android - 在默认浏览器中打开 WebView 链接

转载 作者:搜寻专家 更新时间:2023-11-01 09:44:41 25 4
gpt4 key购买 nike

我想在默认浏览器中打开我的 WebView 链接。我使用了这段代码,但没有用。连日志都没有出现。

webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {

Log.d("urlLoading",url);
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
});

最佳答案

在WebView的源码中定义http://作为链接前缀。

例子:

<a href="http://yourdomain.x/">..</a>

关于android - 在默认浏览器中打开 WebView 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38538954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com