I'm developing an application witch uses WebView to render custom html.
But when I callloadDAtaWithBaseURL(URL, "<html><h1>TEST</h1></html>", "text/html; charset=utf-8;", "utf-8", null);
it shows html itself (not rendered one) on Genymotion emulator.
On my HTC-one, it works fine with rendered html.
Each result is showed as attached.
Does anyone have a same problem or solution? Thanks.
Don't enter mimeType below KitKat.
fun getMimeType(): String? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
"text/html; charset=utf-8"
} else {
null
}
}
loadDAtaWithBaseURL(URL, "<html><h1>TEST</h1></html>", getMimeType(), "utf-8", null);
Java:
if(Build.VERSION.SDK_INT < 21)
webView.loadDataWithBaseURL("about:blank","<html><h1>TEST</h1></html>","text/html", "UTF-8",null);
else
webView.loadDataWithBaseURL("about:blank","<html><h1>TEST</h1></html>","text/html; charset=utf-8", "UTF-8",null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With