Reputation: 561
My app has an Activity that needs 'back' and 'menu' hardware buttons disabled. I disabled the 'back' one with onBackPressed
but I have no idea how to disable the menu button.
Upvotes: 0
Views: 2220
Reputation: 1
I have fix this question in my activity through override onKeyUp(if keyCode is KeyEvent.Menu return true)
Upvotes: 0
Reputation: 332
Update your Gradle files for the app, so you have a current compileSdkVersion,buildToolsVersion, minSdkVersion and targetSdkVersion. Then update your Gradle files for the project so you have the current classpath for Gradle, for instance 'com.android.tools.build:gradle:1.5.0'. This solved the problem for me. I tried the solutions suggested above, but they did not work.
Upvotes: 0
Reputation: 21086
in your Activity
:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
final int keycode = event.getKeyCode();
final int action = event.getAction();
if (keycode == KeyEvent.KEYCODE_MENU && action == KeyEvent.ACTION_UP) {
return true; // consume the key press
}
return super.dispatchKeyEvent(event);
}
Credits to original answer
Upvotes: 0
Reputation: 6914
You should try the key event onKeyDown(). That worked for me.
There is a KEYCODE_MENU you can catch.
Upvotes: 1