I have a PHP service that returns me HTML that I display in a WebView using
activity_news_complete_webview.loadDataWithBaseURL("", html, "text/html", "UTF-8", null);
Also implemented the WebViewClient as follows
WebViewClient webViewClient = new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@TargetApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
view.loadUrl(request.getUrl().toString());
return true;
}
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
};
In doing so when i tap on any , the WebViewClient shows that the url attribute is about:blank but the tag contain proper urla in html variable which i load in the WebView.
Any one who can suggest me a proper solution for this would be a great help, I have read many threads on this issue but haven't found any proper solution because anything i try gives the same issue.
You can use this line replace to .loadDataWithBaseURL();
activity_news_complete_webview.loadData(html, "text/html; charset=utf-8", "UTF-8");
Its working perfectly for me. try this one.
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.