To override Menu
button you can go with the following code..
public void makeContextMenu(ContextMenu contextMenu) {
// Write your code here.
}
To override Back
button there are two options to override close()
method as well as override keyDown(int keycode, int time)
method
1. keyDown(int keycode, int time)
protected boolean keyDown(int keycode, int time) {
int key = Keypad.key(keycode);
if (key == Characters.ESCAPE) {
// do something here
return true;
}
return super.keyDown(keycode, time);
}
2. close()
public boolean onClose() {
if (someCondition) {
// do something
return false;
} else
return super.onClose();
}