-1

I didn't find an answer to this question, so here we go. I have an android library that doesn't implement any View or android Application class, and I need to capture a hardware button press.

I couldn't override / implement any KeyEvent callback function.

Any idea on how can i do it?

Thank you!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
S. Cajal
  • 1
  • 1

1 Answers1

0

You can only capture the home button and recents button without a focusable overlay.

See here for an example of how to do that.

The only way to capture all events would be to use an Accessibility Service.

TheWanderer
  • 16,775
  • 6
  • 49
  • 63
  • I need to catch an "extra" button, because it's a specific hardware that adds functionality. Android recognizes this button events but I couldn't catch it. I'll try your example as soon as I can, thank you. – S. Cajal Nov 09 '18 at 13:01