09-29 21:44:08.557: ERROR/ActivityThread(31036): Activity XXX has leaked IntentReceiver
Android.widget.ZoomButtonsController$1@419abcf0 that was originally registered here. Are you missing a call to unregisterReceiver()?
09-29 21:44:08.557: ERROR/ActivityThread(31036): android.app.IntentReceiverLeaked: XXX has leaked IntentReceiver
android.widget.ZoomButtonsController$1@419abcf0 that was originally registered here. Are you missing a call to unregisterReceiver()?
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): java.lang.IllegalArgumentException: Receiver not registered:
android.widget.ZoomButtonsController$1@419abcf0
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.app.LoadedApk.forgetReceiverDispatcher
(LoadedApk.java:650)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.app.ContextImpl.unregisterReceiver
(ContextImpl.java:1091)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.content.ContextWrapper.unregisterReceiver
(ContextWrapper.java:354)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.widget.ZoomButtonsController.setVisible
(ZoomButtonsController.java:405)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.widget.ZoomButtonsController$2.handleMessage
(ZoomButtonsController.java:179)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.os.Handler.dispatchMessage(Handler.java:99)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.os.Looper.loop(Looper.java:152)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at android.app.ActivityThread.main(ActivityThread.java:4559)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at java.lang.reflect.Method.invokeNative(Native Method)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at java.lang.reflect.Method.invoke(Method.java:491)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:841)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
09-29 21:44:08.917: ERROR/AndroidRuntime(31036): at dalvik.system.NativeStart.main(Native Method)
WebView中包含一个ZoomButtonsController,当使用web.getSettings().setBuiltInZoomControls(true);启用后,用户一旦触摸屏幕,就会出现缩放控制图标。这个图标过上几秒会自动消失,但在3.X系统上,如果图标自动消失前退出当前Activity的话,就会报上面的这些异常。
根据异常信息再参考一下WebView的源码就可以知道ZoomButtonsController有一个register和unregister的过程。但是这两个过程是我们控制不了的,WebView有显示控制的API但我们访问不过。我们能访问到的只有这几个和ZoomButtonsController的控制相关:
void setBuiltInZoomControls(boolean enabled)
void setDefaultZoom(WebSettings.ZoomDensity zoom)
void setDisplayZoomControls(boolean enabled)
void setSupportZoom(boolean support)
试过了一遍都不管用。
最后看终极解析方案吧
在Activity的onDestroy里面加上这么一句:web.setVisibility(View.GONE);把WebView设置为GONE就可以了。
另外,这个问题在2.X上面不存在。
Android 3.X中WebView使用ZOOM崩溃的问题
内容版权声明:除非注明,否则皆为本站原创文章。