Reputation: 2367
how could i intercept the click on the menu button of the device (phone for example).
I need something like OnMenuClick()
.
Upvotes: 4
Views: 1272
Reputation: 2367
I solve it my self, like this
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_MENU||keyCode == KeyEvent.KEYCODE_BACK) && event.getRepeatCount() == 0) {
// my code here...
}
}
Upvotes: 3
Reputation: 3969
implement
onPrepareOptionsMenu(Menu menu)
it gets called every time the menu button is clicked
Upvotes: 0
Reputation: 2415
You need to implement 2 things.
All click events will come to 2.
Upvotes: 0