How to process events of key_down
and key_up
separately (different methods) for the button on a headset of ACTION_MEDIA_BUTTON
?
Asked
Active
Viewed 35 times
0

Dovydas Šopa
- 2,282
- 8
- 26
- 34

Serj Russi
- 1
- 1
-
Please show us the code you have so far. We can't guess what you are trying to do from a one-line description. – BoarGules Jun 04 '17 at 09:47
-
I used a standard script (the description on this website) for processing of pressing of the ACTION_MEDIA_BUTTON button But by long pressing Google search is caused, and I should process key_down and key_up separately – Serj Russi Jun 04 '17 at 10:53
-
[code like this](https://stackoverflow.com/questions/6287116/android-registering-a-headset-button-click-with-broadcastreceiver) – Serj Russi Jun 04 '17 at 11:01
-
Really, I haven't correctly raised a question)) In that example there is a division, on events necessary for me..., but how to disconnect Google search by long pressing the button? – Serj Russi Jun 04 '17 at 11:51
-
For this purpose it is necessary to shut down the Google app in settings. And search won't appear – Serj Russi Jun 04 '17 at 12:12
-
But shutdown search Google, hasn't solved a problem... By short-term pressing everything works, but if to clamp the button for some time, then events aren't processed – Serj Russi Jun 04 '17 at 12:22
-
if (action == KeyEvent.ACTION_DOWN) { action(1); } if (action == KeyEvent.ACTION_UP) { action(2); } – Serj Russi Jun 04 '17 at 12:23