New WebView in Android KitKat

My application is using WebView

to display long text

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView mWebView = new WebView(getApplicationContext());

    setContentView(mWebView);

    String s = getHtml(); //get a long html from a file

    webView.loadDataWithBaseURL("file:///android_asset/", s, "text/html", "UTF-8", null);
}

      

the app works well on older versions of Android,
but when run on KitKat, this error appears in the log when the WebView is created or destroyed:

libGLESv2(21582): HWUI Protection: wrong calling from app context F:ES3-glDeleteShader

      

I have read "Migrating to WebView to Android 4.4" but I cannot solve the problem.

How to fix it?

+3


source to share


2 answers


Change

WebView mWebView = new WebView(getApplicationContext());

      



to

WebView mWebView = new WebView(this);

      

+3


source


add



webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

      

+2


source







All Articles