I am using the following Java code to create some HTML for displaying content.
public String htmlFromArrayList(ArrayList<TSI> a) {
StringBuilder returnStringBuilder = new StringBuilder();
for (TSI i : a) {
returnStringBuilder.append("<h3>");
returnStringBuilder.append(i.itemTitle);
returnStringBuilder.append("</h3><p>");
returnStringBuilder.append(i.itemText);
returnStringBuilder.append("</p>");
}
return returnStringBuilder.toString();
}
To load the string I use
mWebView.loadData(htmlFromArrayList(mSummaryItemArrayList), "text/html", null);
Now this works for about 60% to 70% of my ArrayList<TSI>, but for the others I get an error when I open the TSI:
The web page at data:text/html;null,%3Cp%E.......p%3E might be temporarily down or it may have moved...
I am assuming this has something to do with strange characters in the charset. What does the error message mean?
Do you have strange characters like percent signs, backslashes or other non alphabetical characters in your i.itemText or i.itemTitle? If you do, that will cause the ‘webpage not found’ problem.
http://code.google.com/p/android/issues/detail?id=4401
Also, you are not passing in an Encoding, try passing in “UTF-8” instead of null.
This problem can be worked around by replacing all % symbols with the HTML entity (Ampersand Pound 37): (%).
There are reports that if any Chinese characters get fed into your webView, you can still get the “page not found” problem even if you handle the percent sign. So the work around is to try this:
This works with everything plus Chinese characters:
Source
http://code.google.com/p/android-rss/issues/detail?id=15