Error: WebView.destroy() called while still attached 解决方法

一般是在 Activity 的 OnDestroy 中处理 webView,代码如下:

    public void onDestroy() {
        super.onDestroy();
        if (webView != null)
            webView.destroy();
    }

但会出现错误:Error: WebView.destroy() called while still attached

解决方法如下:

    public void onDestroy() {
        if (webView != null) {
            ViewGroup parent = (ViewGroup) webView.getParent();
            if (parent != null) {
                parent.removeView(webView);
            }
            webView.removeAllViews();
            webView.destroy();
        }
        super.onDestroy();
    }
}

  

时间: 2024-08-27 12:20:26

Error: WebView.destroy() called while still attached 解决方法的相关文章

WebView.destroy() called while still attached 的解决办法

可以现在webView的父组件中删除该webview,然后再Destroy parent.removeView(webView); 然后 webView.removeAllViews(); webView.destroy(); WebView.destroy() called while still attached 的解决办法

Error:Execution failed for task ':app:transformClassesWithDexForDebug'解决方法

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.transform.api.TransformException: java.util.zip.ZipException: duplicate entry: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 类似问题我通过审查build.gradle引用的lib,把所有功能重复

gSoap的“error LNK2001: 无法解析的外部符号 _namespaces”解决方法

在工程中添加宏 WITH_NONAMESPACES gSoap的"error LNK2001: 无法解析的外部符号 _namespaces"解决方法

androidstudio打包时出现错误Error:Execution failed for task ':app:transformClassesWithDexForRelease'解决方法

今天在android studio上打包项目时,遇到了Error:Execution failed for task ':app:transformClassesWithDexForRelease这么个错误,记得之前也遇到过这种问题,却如何想不起怎么解决的,只好再次在网上查资料,总算是解决了 这个问题的原因倒是简单的很,是因为我项目中应用的jar包重复,我在build.gradle文件的dependencies中重复依赖了libs下的jar包,将下边的删除即可 androidstudio打包时出

在WSL中安装swool报错 error: unrecognized command line option '-V' 的解决方法

Windows Subsystem for Linux Ubuntu中使用pecl安装swool时遇到错误"error: C compiler cannot create executables"."error: unrecognized command line option '-V'" 解决方法 先看解决方法, 将gcc版本降低到4.8即可,因为高版本gcc取消了-V参数: sudo apt install gcc-4.8 -y sudo update-alte

WebView.destroy() called while still attached 的解决的方法

能够如今webView的父组件中删除该webview,然后再Destroy parent.removeView(webView); 然后 webView.removeAllViews(); webView.destroy();

eclipse启动出现“An Error has Occurred. See the log file”解决方法

最近在启动eclipse时出现了“An Error has Occurred. See the log file”的错误,点击确定后也不能启动eclipse.查看log文件,出现类似: java.lang.ClassNotFoundException: javax.xml.parsers.SAXParserFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPri

Command "python setup.py egg_info" failed with error code 1一种问题的解决方法

问题描述:无论是你在pycharm中直接使用import and install命令,还是pip的时候出现了Command "python setup.py egg_info" failed with error code 1这样的问题描述,需要考虑可能pip的这个源里面没有对应的python3.5的模块 解决方法:通常可以直接google "XXX for python3.5",或者在github中找到对应的python3.5的项目,将对应的.py文件添加到pyt

Spark SQL: Error in query: undefined function错误的解决方法

本文原文出处: http://blog.csdn.net/bluishglc/article/details/50748937 严禁任何形式的转载,否则将委托CSDN官方维护权益! 问题描述 如果你在Spark SQL上试图调用在HIVE注册的自定义函数(UDF)时,你可能会遇到这样的错误: Spark SQL: Error in query: undefined function xxxxxx 这个问题发生在Spark 1.5.0, 1.5.1和1.5.2版本上,对此Spark官方有一个专门的