我将WebView的内容设置为;

String displayBodyText = "<a href="scheme:/user_abd/data?q=from%3A%22ammar%40mydomain.com%22#title=%40Ammar%20">Ammar</a>"
webView.loadData(displayBodyText , "text/html", "utf-8");


并将WebViewClient设置为;

linkDetailWebView.setWebViewClient(new WebViewClient() {
                        @Override
                        public boolean shouldOverrideUrlLoading(WebView view, String url) {
                            Log.d("TAG", url);
                            return true;
                        }
                    });


单击数据中的链接时,我得到的是scheme:/user_abd/data?q=from:而不是scheme:/user_abd/data?q=from%3A%22ammar%40mydomain.com%22#title=%40Ammar%20

我无法获得WebView的这种行为。

最佳答案

试试这个代码,我检查了它是否对我有用

String displayBodyText = "<a href=\"scheme:/user_abd/data?q=from:&#34;[email protected]&#34;#title=@Ammar\">Ammar</a>";
web_view.loadData(displayBodyText , "text/html", "utf-8");


Webview客户端

web_view.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            String m_url = URLDecoder.decode(url);
            Log.e("TAG",m_url);

            return true;
        }
});

关于android - WebViewClient.shouldOverrideUrlLoading提供无效的网址,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29507482/

10-11 00:08