问题描述
这是在警告我得到:
03-02 14:38:43.980:W / InputEventReceiver(3961):试图完成一个输入事件,但输入的事件接收器已经被释放
我已经从一个普通的 RES /菜单/ activity_menu.xml
文件生成的菜单。我在处理这些事件正是在http://developer.android.com/guide/topics/ui/menus.html#options-menu
The menu I have was generated from a regular res/menu/activity_menu.xml
file.I'm handling the events exactly as detailed on http://developer.android.com/guide/topics/ui/menus.html#options-menu
当我点击垂直三个点打开溢出菜单并取消了它,我得到的警告。似乎是如何捕捉到它的触发知之甚少。任何想法?
When I click the vertical three dots to open the overflow menu and cancel out of it, I get that warning. There seems to be little knowledge of how to catch its trigger. Any ideas?
推荐答案
这是不是对你的工作有关。
This is not related with your work.
溢出菜单由PopupWindow实现。当用户触摸关闭PopupWindow,ACTION_DOWN事件排队应用程序的消息队列。然后,它被传递到查看通过ViewPostImeInputStage类,并最终ViewPostImeInputStage发送此输入事件PopupWindow的的onTouchEvent监听器。
Overflow menu is implemented by PopupWindow. When user touch to close PopupWindow, ACTION_DOWN event queued to app's Message queue. Then it is delivered to View through ViewPostImeInputStage class and finally ViewPostImeInputStage send this input event to PopupWindow's onTouchEvent listener.
@Override
public boolean onTouchEvent(MotionEvent event) {
final int x = (int) event.getX();
final int y = (int) event.getY();
if ((event.getAction() == MotionEvent.ACTION_DOWN)
&& ((x < 0) || (x >= getWidth()) || (y < 0) || (y >= getHeight()))) {
dismiss();
return true;
} else if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
dismiss();
return true;
} else {
return super.onTouchEvent(event);
}
}
dissmiss()尝试关闭PopupWindow和PopupWindow :: onDetachedWindow调用WindowInputEventReceiver ::处理()第一。
dissmiss() try to close PopupWindow and PopupWindow::onDetachedWindow call WindowInputEventReceiver::dispose() first.
然后ViewPostImeInputStage调用WindowInputEventReceiver :: finishInputEvent完成该ACTION_DOWN事件。然而WindowInputEventReceiver实例已经设置成它抛出警告信息。
And then ViewPostImeInputStage call WindowInputEventReceiver::finishInputEvent to finish that ACTION_DOWN event. However WindowInputEventReceiver instance is already disposed so it throw warning messages.
您可以将它通过断点调试。开放InputEventReceiver.java(需要框架/基/ Android源$ C $ C)和Dispose方法设置断点。
You can debug it by breakpoint. open InputEventReceiver.java(need android source code at framework/base/) and set breakpoint at dispose method.
这篇关于取消在Android 4.1.x的动作条上溢菜单时警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!