How do I temporarily disable/bypass the Android OnTouchEvent
-
27-09-2019 - |
문제
I'm currently using the event
@Override
public boolean onTouchEvent(MotionEvent ev)
{
To provide feedback from the user for game I'm writing. This event fires off some game control events that take some time to complete (because there is animation involved). The problem I'm having is during the animation if I keep touching the screen (AKA firing this event), I will get a timeout error:
10-02 21:58:30.776: ERROR/ActivityManager(67): Reason: keyDispatchingTimedOut
Basically while the animation is running, I do not need this event, although it would be nice to queue it.
What can I do to prevent the timeout and either queue the event, or temporarily disable it?
Thanks.
해결책
Are you by any chance blocking the UI thread? There should be absolutely no reason to do what you are asking for (and it's not even possible :)
다른 팁
Beside what Romain said.
You might want to sleep() on your onTouchEvent.
Easy way to implement that is add transaperent layout over it (add it in your xml fill parent height and width).
in animation start transaparentlayout.setClickabe(true); in animation end transaparentlayout.setClickabe(false);
very simple.