M
M
Maxim Moseychuk2015-03-25 03:34:30
Java
Maxim Moseychuk, 2015-03-25 03:34:30

How to process button clicks in real time?

Overridden the dispatchKeyEvent method in the Activity to handle pressing the volume buttons.
When the volume down button is pressed very quickly (5 times per second somewhere), the method is not called. When the tempo decreases, all events (KeyEvent) arrive (including those that "hung" at a high tempo). At the same time, the events themselves are created exactly at the moment the button is pressed (getEventTime returns quite truthful values).
With the volume up button, such problems were not noticed. Checked on the emulator 4.1, and on the phone 5.1. Even the system volume control is subject to this effect.
Maybe there is a way to force the Activity to process the accumulated queue forcibly, by a timer for example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2015-03-25
@jkotkot

I am not an android master, but apparently, the volume does not change quickly and, therefore, you need to change it in a separate thread. Well, or some kind of processing queue .. for example, if a new task has already arrived, then we cancel the previous one and immediately change the volume to some other level.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question