Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Invalid
-
3.5.0
-
None
-
None
Description
I have the same problem in with Cordova 3.5.0 on Android 4.4.2 emulator and Galaxy S3 4.1.2. After investigation, the problem should be in the program CordovaWebView.java.
CordovaWebView.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { ... // Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { if (this.lastMenuEventTime < event.getEventTime()) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); } this.lastMenuEventTime = event.getEventTime(); return super.onKeyUp(keyCode, event); // <== Problem Line } // If search key else if (keyCode == KeyEvent.KEYCODE_SEARCH) { this.loadUrl("javascript:cordova.fireDocumentEvent('searchbutton');"); return true; } ...
When it is changed as follows, it works fine.
CordovaWebView.java
// Legacy else if (keyCode == KeyEvent.KEYCODE_MENU) { if (this.lastMenuEventTime < event.getEventTime()) { this.loadUrl("javascript:cordova.fireDocumentEvent('menubutton');"); } this.lastMenuEventTime = event.getEventTime(); return true; // <== Changed as }
I think the problem is calling the super.onKeyUp() method and it throws a RuntimeException actually. But at this point, the event is "handled", there is no reason to delegate the control to the parent class. Referring to a similar case below for the search button, it just returns true when the javascript event handler is executed.