Attempted to Finish an Input Event …

Posted by in Software

… but input event receiver has already been disposed.

This is the error I got while trying to do something off a menu in Android. Silly really. The message is not too revealing so I ended up scouring the net for an answer and scratching my head afterwards…

With a service

My problem was trying to launch a service; I figured it out with a single step:

Disable the filter in Android Studio (logcat). Then, just before this message, I got another one:

which gave me the real reason: I forgot to add the service to my manifest file. Lesson learned.

With a button

This question refers to the same problem, but in a different scenario: a button’s event displaying a Toast.

My solution involves the same “disable the filter” from above and see the real reason.

To decouple the Toast from an ephemeral widget, I have a solution; write a wrapper:

and use it via a Handler object, e.g.:

This way, even if the source goes away, the Toast gets shown.

A little experiment: If you find this post and ad below useful, please check the ad out :-)