美文网首页
WebView 遇到的坑

WebView 遇到的坑

作者: siyanGo | 来源:发表于2017-07-21 15:18 被阅读309次

手机:华为荣耀6plus 系统为 Android 4.4.4
当需要设置允许调用Js的时候会出错
settings.setJavaScriptEnabled(true);

Activity has leaked ServiceConnection com.android.org.chromium.com.googlecode.eyesfree.braille.selfbraille.SelfBrailleClient$Connection@41e46c20 that was originally bound here

如上发生了内存泄漏,应该是某个组件持有context,生命周期要比Activity长,引发的泄漏
将Webview 的初始化 改成 super(context.getApplicationContext());
和super(context.getApplicationContext(), attrs);
就不会引发泄漏了

相关文章

网友评论

      本文标题:WebView 遇到的坑

      本文链接:https://www.haomeiwen.com/subject/nglekxtx.html