【问题标题】:New WebView in Android KitKat problemsAndroid KitKat 中的新 WebView 问题
【发布时间】:2014-10-05 06:49:36
【问题描述】:

我的应用使用WebView 来显示长文本

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);
}

该应用在旧版本的 Android 上运行良好,
但是在KitKat上运行时,在创建或销毁WebView时logcat中会出现这个错误:

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

我已阅读“迁移到 Android 4.4 中的 WebView”,但我无法解决问题。

我该如何解决这个问题?

【问题讨论】:

  • 在 4.4.4 上遇到同样的问题。有人知道是什么原因造成的吗?

标签: android webview android-4.4-kitkat hwui


【解决方案1】:

改变

WebView mWebView = new WebView(getApplicationContext());

WebView mWebView = new WebView(this);

【讨论】:

  • @konkot 没用是什么意思?请清除项目并重试。如果不同,请发布 logcat 信息。
  • logcat 中仍然出现该错误:libGLESv2(21582): HWUI Protection: wrong call from app context F:ES3-glDeleteShader
【解决方案2】:

添加

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多