title: Long key press handling in android 1.5
body: <p>I want to handle key press and long key press for the key code KEYCODE_BACK(back button). can any one suggest me how to do this in android 1.5(API level 3).</p>
  
  <p>Here is the code.</p>
  
  <pre><code>public boolean onKeyDown(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_BACK) {
  
                  if(event.getRepeatCount()==0) {
                     // normal key press
                     //Do something here
                     // But problem is, this code is hitting for long press also, how to avoid this
                  } else {
                      // Long key press
                      //Do something here
                  }
                  // Always consume back key event by returning true
                  //so that default behavior of back is overrided
                  return true;
              }
          return super.onKeyDown(keyCode, event);
      }
  </code></pre>
  
  <p>The problem is the code for normal key press is also executed on long press. I want to avoid this.</p>
  
  <p>Note: I can't use methods like <code>onKeyLongPress()</code> , <code>startTracking()</code> etc as they are introduced in API level 5</p>