1

I try to handle a long press event on the Navigation Bar (soft keys) to perform an action Inside my Activity. My phone is runing Android 4.4.4.

I tried to override onKeyDown() and onKeyLongPress(), but none of this Handler receive this event.

I didn't find any example of this. Is it possible to do and how ?

  • AFAIK it is not possible, since those buttons are not part of your application (the same way detecting "home" press is not possible). – shkschneider May 07 '15 at 14:13
  • Thanks ! That's frustrating. Apparently it's posible to handle de Back button : http://stackoverflow.com/questions/8956587/android-code-to-handle-return-button-of-the-softkey-or-return-button-which-is-o – Thierry Campiche May 07 '15 at 14:31

1 Answers1

2

AFAIK it is not possible, since those buttons are not part of your application (the same way detecting "home" press is not possible).

Yes, the "back" button has its API callback, Activity.onBackPressed() but there is not API for the other buttons, which are only handled by the system/launcher.

So I'm afraid there is no way to achieve what you asked. (Sadly if you will, but that is by design and I'm sure you can see why).

shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • Thanks ! I just wander on things which is related to this question. On some Android device, the physical "menu" button is used to list the runing app and sometimes open a Menu on long press on some application. I wander how it's done and if it behave the same with soft Keys ? – Thierry Campiche May 07 '15 at 15:20