18

This is the warning I'm getting:

03-02 14:38:43.980: W/InputEventReceiver(3961): Attempted to finish an input event but the input event receiver has already been disposed.

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?

alexismorin
  • 787
  • 1
  • 6
  • 21
  • Its a warning, and its not part of your app. Looks like a problem in Android itself. You should be able to ignore it safely – Raghav Sood Mar 02 '13 at 14:05
  • are you using ActionBar Sherlock? – Justin Vartanian Mar 02 '13 at 15:53
  • @JustinV. I'm using stock Android for this. – alexismorin Mar 03 '13 at 02:05
  • I'm gonna have to agree with @RaghavSood. This isn't a problem with your app. This is a problem with android. ActionBarSherlock has an [issue](https://github.com/JakeWharton/ActionBarSherlock/issues/693) open on this warning, but, obviously it is not specific to just ActionBarSherlock – Justin Vartanian Mar 03 '13 at 04:41
  • 7
    Call me OCD but it's just nice to be able to produce an application with no warnings through and through. Thanks for quick replies. I'll keep an eye out for a fix to this problem. – alexismorin Mar 03 '13 at 11:52
  • are there any progress? – Compaq LE2202x Sep 05 '13 at 12:11
  • 1
    I'd like to know about that warning too, please if anyone knows to respond – Sartheris Stormhammer Nov 15 '13 at 10:30
  • I am facing a similar issue, but it is a problem for me. The spinner works most of the time, but sometimes it still opens and close, and you can click on it. But no action is done when clicking, just closing spinner. Any new information on that ? I had the warning on GS3 – Seynorth Dec 31 '13 at 15:41
  • 1
    The same problem when I cancel a PopupMenu on Android 4.4.4. – TechAurelian Sep 10 '14 at 12:45

1 Answers1

14

This is not related with your work.

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() try to close PopupWindow and PopupWindow::onDetachedWindow call WindowInputEventReceiver::dispose() first.

And then ViewPostImeInputStage call WindowInputEventReceiver::finishInputEvent to finish that ACTION_DOWN event. However WindowInputEventReceiver instance is already disposed so it throw warning messages.

You can debug it by breakpoint. open InputEventReceiver.java(need android source code at framework/base/) and set breakpoint at dispose method.

skyisle
  • 576
  • 8
  • 11
  • Thanks for sharing this! But how to get rid of this warning? I'm not quite understanding the main problem? In Marshmallow, once the PopupMenu dismissed, the keyboard is hidden automatically and lose the menu and the keyboard, as the I've created custom IME with PopupMenu. Can you please help? – Mohammed AlBanna Aug 08 '16 at 22:37