cadlg wrote:Hi guys.
Some time ago I was trying to handle the "back" key event, but it doesn't work as expected.
It continues propagating wheather you return true or false.
I think "home" and "back" key events cannot
currently be managed this way...
Regards,
cadlg
No you can override the back key. I just reran my code and it still works as expected. I have an application with a webview, I wanted to override the back key in the case there were pages to go back, and otherwise to close the activity as normal. Here is said code:
public boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode==KeyEvent.KEYCODE_BACK){
if(ourWebview.canGoBack()){
ourWebview.goBack();
return true;
}else{
return super.onKeyDown(keyCode, event);
}
}
return super.onKeyDown(keyCode, event);
}