I am new to Android development, but found that the touch handler is also very concise. The default sample updates the object and does it quite a lot - this inevitably makes the garbage collector angry. I managed to get it to work less succinctly by calling "Thread.sleep (10);" inside the launch function.
I assume that replacing the “new Runnable” with a circular object buffer will improve performance, but I have not explored this yet. I think that touch events occur in a separate branch, and this can cause complications.
Override public boolean onTouchEvent(final MotionEvent event)
{
queueEvent(
new Runnable()
{
public void run()
{
int action = event.getAction();
try
{
Thread.sleep(10);
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
});
return true;
}
source
share