title: Strange behavior with the back button in Android when trying to get long presses
body: <p>I found a strange behavior in my Android application while trying to implement a long press catch event for the "back" button.</p>
  
  <p>I use the following code for all the physical keys I want to manage in all of my activities (I removed unsignificant parts):</p>
  
  <pre><code>// Called when the user presses the "physical" buttons
  @Override
  public boolean dispatchKeyEvent(KeyEvent aEvent)
  {
      // Used to know which event was triggered
      int action = aEvent.getAction();
      int keyCode = aEvent.getKeyCode();
  
      // Get the pressed button
      switch (keyCode)
      {
          // Key "back"
          case KeyEvent.KEYCODE_BACK:
              // If the button is pressed down
              if (action == KeyEvent.ACTION_DOWN)
              {
                  // DEBUG
                  App.debug("BACK button is pressed!");
              }
              // If the button is released
              else if (action == KeyEvent.ACTION_UP)
              {
                  // DEBUG
                  App.debug("BACK button is released!");
              }
          return true;
  
          [...]
  
          default:
          return super.dispatchKeyEvent(aEvent);
      }
  }
  </code></pre>
  
  <p>The "App.debug()" method is only a wrapper for the "Log.d()" one.</p>
  
  <p>When I test my code above, with a simple "tap" on the "back" button, I can see the expected lines to appear in the logcat ("BACK button is pressed!" when I touch the back button and "BACK button is released!" when I remove my finger).</p>
  
  <p>Now when I keep my finger on the back button, I can ONLY see 2 times "BACK button is pressed!" to appear in the logcat, with aproximately half a second between them. Then when I release the button (say 10 seconds later) I see the "BACK button released!" sentence appearing as expected. Here is what I have in the logcat:</p>
  
  <p><code>BACK button is pressed!</code>  -> as soon as I touch the button with my finger</p>
  
  <p><code>BACK button is pressed!</code>  -> half a second later</p>
  
  <p><code>BACK button is released!</code> -> as soon as I remove my finger</p>
  
  <p>Why does the "back" button long press ONLY triggers two "button down" events?</p>
  
  <p><strong>EDIT:</strong> I think I wasn't clear enough, sorry for this (English is not my natural language)... The problem is I ONLY have 2 events triggered as long as my finger remains on the button where it should trigger many many "button down" events until I remove my finger. Added "only" where it should be in my description.</p>
  
  <p><strong>EDIT 2:</strong> After some verification, it seems to only occur on some devices... Maybe Android version is involved here ?</p>
  
  <p>"Not working as expected" tested devices are:</p>
  
  <ul>
  <li>Sony Xperia Z1 with Android 4.4.2</li>
  <li>Klipad Smart D71 with Android 4.4.2</li>
  </ul>
  
  <p>"Working as expected" tested devices are:</p>
  
  <ul>
  <li>Samsung Galaxy Grand Prime with Android 4.4.4</li>
  <li>Huawei Y5 with Android 5.1.1</li>
  </ul>
  
  <p>Any idea?</p>
  
  <p>Have a nice day.</p>