views:

59

answers:

2

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.

A: 

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 :)

Romain Guy
Can you explain "blocking the thread?" I probably am doing it. I'm basically doing my own animation. One thread just draws the screen, while the other thread uses delays between moving the drawables. And this OnTouchEvent fires off moving the drawables.
A: 

Beside what Romain said.
You might want to sleep() on your onTouchEvent.

Miguel Morales
Unfortunately, I can not do this because the animation might take anywhere from 0.5 seconds, to 5 or more.
What do you mean? How are you running your animation? I'm using GLSurfaceView which uses its own render thread. When I receive a touchevent I set a boolean to play an animation. Then on the render thread, I check whether to play the animation during that render run or not. You can still sleep on the event without affecting your animation.
Miguel Morales