WebView 遇到的坑

手机:华为荣耀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 遇到的坑)