0

I am trying to use the the Android Media Button in an application (on Android 4.4.2) as PTT (push to talk) button.

I am able to get the key pressed and key up events for short key presses (although they seem to occur shortly after each other when the key is already released) in my MediaButtonEventReceiver.

But I get no event at all when I press the media button for a longer time.

NB: I have already deinstalled the Google Speech Search.

Is there a way to get the media button events when they actually occur (ie without delay and for longer presses)?

I do not need the Media Player or Google Search to work on the device.

Ruediger Jungbeck
  • 2,836
  • 5
  • 36
  • 59
  • http://stackoverflow.com/questions/19856758/how-to-detect-long-press-of-volume-button-in-android – Omar Aflak May 10 '16 at 12:56
  • I want to use the media button, not the volume buttons and my impression is, that I only get the key_pressed event when the button has already been released, which makes the proposed solution idea, which starts the timer on key_pressed useless for me. – Ruediger Jungbeck May 10 '16 at 13:04
  • what do you mean by "media button" ? – Omar Aflak May 10 '16 at 16:33
  • The (middle) button on the headset cable that you use to pause play our advance to the next song. Long pressing normally activated Okay Google – Ruediger Jungbeck May 10 '16 at 18:42
  • If you have Google Now installed it may be the cause: http://stackoverflow.com/questions/20991248/google-now-wont-let-my-app-detect-headset-button-long-click – Omar Aflak May 10 '16 at 18:47
  • I need the key press and release events when they actually occur, not delayed, or marked as long presses, because I want to open/close the audio channel at that time. – Ruediger Jungbeck May 10 '16 at 20:18
  • I can see all button presses in adb shell getevent at the right time.But do I really need a NDK module (and a JNI interface) for that? – Ruediger Jungbeck May 13 '16 at 11:25

0 Answers0