piruzi
piruzi

Reputation: 21

Android Physcal Menu Button Event

I want to handle physcal menu button event for block user who want to exit my application. I tried onKeyDown(), onClick() and onCreateOptionsMenu() override methods. None of them doesnt work for me. How can I detect press physcal menu button? Thank you.

PS: Android version 8.1.0

Upvotes: 1

Views: 36

Answers (1)

snachmsm
snachmsm

Reputation: 19243

what is "physcal menu button"? you are probably talking about Home button which is causing your app goes to background: thats not possible for security reasons ofc. if this would be possible then some unfair apps will take control on users device/screen, also there would be possibility of bug in some app causing that it can't be closed. Home* and Power buttons can't be hijacked or set for handling custom click only, at most you can detect these were pressed, but still they do their job

*well, Home nowadays is a gesture

Upvotes: 1

Related Questions