Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loadData tries to use data as url in webview

page = "<!DOCTYPE HTML><html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" +
                    "</head><body>" + page + "</body></html>";
            webContent.loadData(page, "text/html;charset=UTF-8", "UTF-8");

On the call to loadData the webview gives "URL is invalid", in the onReceivedError callback the url is "data:text/html;charset=UTF-8;UTF-8,%3C!DOCTYPE%20HTML%3E .... /body%3E%3C/html%3E". This doesn't happen on all the data I load.

Note:

  • in jelly bean everything works fine, this problem occurs while testing on 2.3
  • I've tried loading data with loadDataWithBaseURL but the webview does't interpret the html, just shows the string content.

Thank you!

like image 427
Misca Avatar asked Oct 19 '12 13:10

Misca


1 Answers

webContent.loadDataWithBaseURL(null, page, "text/html", "UTF-8")

works for me, while with loadData() I get sometimes your problem

like image 54
sherpya Avatar answered Sep 25 '22 02:09

sherpya