I don't think this is a duplicate, but this question may be relevant.
As of title: this works perfectly on android 2.3.3, randomly shows a blank page on 4.0.1. It usually works at first, then start displaying blank pages until the application is reinstalled.
The code I'm using to display a simple (html only) webpage is a follows:
@Override
public void afterTextChanged(final Editable arg0){
final String result = getResult();
final String base64 = encode(result);
//This is the WebView
results.loadData(base64, "text/html; charset=utf-8", "base64");
}
private String encode(final String value){
try{
final byte[] bytes = value.getBytes("UTF-8");
final String base64 = Base64.encodeToString(bytes,
android.util.Base64.DEFAULT);
return base64;
}
catch(UnsupportedEncodingException e){
return "YOULOOZE";
}
}
Check that your HTML is well formatted. I am not sure of the Doctype it validates against.
This happened to me because I used
<script ... />
instead of
<script ...></script>
Any tiny error will make your webview fail silently.
I'm not sure that is your solution but can help. Since Android 4.0 WebKit updated into version 534.30. I noticed that on some web pages, after it has completed loading, the WebView redirects its content to a new page that says the following: "Webpage not available The webpage at file:///android_asset/webkit/ might be temporarily down or it may have moved permanently to a new web address". This is bug of new version of WebKit, in my case javascript from assets folder don't work in offline.
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