Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-7307

On Android 4.1 events are only sent on every second menu button press (Cloned)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Invalid
    • 3.5.0
    • None
    • cordova-android
    • 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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              keith.wong@objectvalley.com Keith Wong
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: