Web view Error using HTML content in Android

夙愿已清 提交于 2019-12-13 04:24:55

问题


Errors I am getting when passing Html(textstring) content value to webview.loaddata(textstring , "text/html", "utf-8");

Works fine in gingerbread,jellybean etc....but facing problem in Ice cream sandwich....Please help me to solve this

02-08 13:52:56.899: W/webcore(1694): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:1671)
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.WebViewCore$EventHub.access$7800(WebViewCore.java:920)
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.WebViewCore.removeMessages(WebViewCore.java:1783)
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.WebView.sendOurVisibleRect(WebView.java:2858)
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:586)
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.ZoomManager.access$1700(ZoomManager.java:49)
02-08 13:52:56.899: W/webcore(1694):    at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:977)

回答1:


Try this I this that will help to you

String data = ...;  // the html data
String base64 = android.util.Base64.encodeToString(data.getBytes("UTF-8"),  
android.util.Base64.DEFAULT);
webView.loadData(base64, "text/html; charset=utf-8", "base64");

and you try this also

   webView.getSettings().setDefaultTextEncodingName("utf-8");      
   webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);

And also refer this link

UTF-8 encoding on WebView and ICS



来源:https://stackoverflow.com/questions/14768567/web-view-error-using-html-content-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!