java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController
java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController
·
公司APP遇到了一个奇怪的BUG,进入某个带有WebView的页面,操作下经常行发生崩溃。异常信息如下:
java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController$1@bdd2e5a
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:765)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1683)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:511)
at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:404)
at android.widget.ZoomButtonsController$2.handleMessage(ZoomButtonsController.java:178)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5280)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
网上大致的解决方案:
1.在Activity的onDestroy里面加上这么一句:web.setVisibility(View.GONE);把WebView设置为GONE就可以了。
延迟destroy webview
if(webview != null) {
webview.getSettings().setBuiltInZoomControls(true);
mWebView.setVisibility(View.GONE);
long timeout = ViewConfiguration.getZoomControlsTimeout();//timeout ==3000
Log.i("time==",timeout);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
mWebView.destroy();
}
}, timeout);
}
2.重写WebView的finish方法,通过getDecorView:这个方法获取顶级视图,然后移除所有View,问题得到解决。
/**
* 防止webview缩放时退出崩溃。
*/
@Override
public void finish() {
ViewGroup view = (ViewGroup) getWindow().getDecorView();
view.removeAllViews();
super.finish();
}
我用了通通不管用,,最后发觉是mumu模拟器会报错,,真机运行一点事情没有!!!!
参考
https://www.jianshu.com/p/2ff286e305f7
更多推荐
已为社区贡献18条内容
所有评论(0)