title: Capture event on Android after some seconds
body: <p>I want to add a button to my app in Android and capture the event on this button (onclick) after a couple of seconds pushing the button, so it doesn't react at the first touch.
  Is this possible to achieve on Android?</p>
  
  <p>Right now I have the next code that captures an onclick on the home button (in the ActionBar).</p>
  
  <pre><code>public boolean onOptionsItemSelected(MenuItem item) {
      if (item.getItemId() == android.R.id.home) {
          showSendLogAlert();
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>When an user clicks on this button, it sends a little report by email, and I don't want to launch this event accidentally, that's why I want the user to push a couple of seconds in order to be sure he wants to do that operation.</p>
  
  <p><strong>Solution:</strong></p>
  
  <p>Based on the comments below I got this working solution:</p>
  
  <pre><code>@Override
  protected void onCreate(final Bundle savedInstanceState) {
      // stuff
  
      // Set the home button clickable
      getActionBar().setHomeButtonEnabled(true);
  
      // Define a long click listener instead of normal one
      View homeButton = findViewById(android.R.id.home);
      homeButton.setOnLongClickListener(new View.OnLongClickListener() {
  
          @Override
          public boolean onLongClick(View v) {
              showSendLogAlert();
              return false;
          }
      });
  
      // more stuff
  }
  </code></pre>