Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android. WebView and loadData

It's possible to use following method for content's setting of a web-view loadData(String data, String mimeType, String encoding)

How to handle the problem with unknown encoding of html data?!

Is there a list of encodings?!

I know from my college that in my case html comes from DB and is encoded with latin-1. I try to set encoding parameter to latin-1, to ISO-8859-1 / iso-8859-1, but still have problem with displaying of special signs like ä, ö, ü.

I'll be very thankful for any advice.

like image 976
Tima Avatar asked Oct 18 '10 17:10

Tima


People also ask

What is alternative of WebView in Android?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

What is Android WebView?

Android WebView is a system component for the Android operating system (OS) that allows Android apps to display content from the web directly inside an application.

Is Android WebView deprecated?

This interface was deprecated in API level 12. This interface is now obsolete.


1 Answers

myWebView.loadData(myHtmlString, "text/html; charset=UTF-8", null); 

This works flawlessly, especially on Android 4.0, which apparently ignores character encoding inside HTML.

Tested on 2.3 and 4.0.3.

In fact, I have no idea about what other values besides "base64" does the last parameter take. Some Google examples put null in there.

like image 133
patryk Avatar answered Oct 03 '22 01:10

patryk