Resolved, give me a lot of “useful” for this answer, because it is really a nasty web search error, and I think my answer will help many of you!
If your html page really contains one of the characters "%", "\" or "#", the loadData () method will fail! So you need to manually replace this chr and here is my class:
public class BuglessWebView extends WebView{ public BuglessWebView(Context context) { super(context); } public BuglessWebView(Context context,AttributeSet attributes){ super(context,attributes); } public BuglessWebView(Context context,AttributeSet attributes,int defStyles){ super(context,attributes,defStyles); } @Override public void loadData(String data, String mimeType, String encoding) { super.loadData(solveBug(data), mimeType, encoding); } private String solveBug(String data){ StringBuilder sb = new StringBuilder(data.length()+100); char[] dataChars = data.toCharArray(); for(int i=0;i<dataChars.length;i++){ char ch = data.charAt(i); switch(ch){ case '%': sb.append("%25"); break; case '\'': sb.append("%27"); break; case '#': sb.append("%23"); break; default: sb.append(ch); break; } } return sb.toString(); } }
here is the discussion link in google code: http://code.google.com/p/android/issues/detail?id=1733
Phate source share