title: Android Webview back pressed one click to go back and double click to exit
body: <p>Hello Guys i'm trying to make the back button on a webview go back when pressed one time and finish the activity with an alert when pressed twice</p>
  
  <p>the problem is that when I try to double click it runs as if I had clicked one .. he does not expect the run time of double click</p>
  
  <p>thanks!</p>
  
  <p>Code</p>
  
  <pre><code>      public void onBackPressed()
       {
        if (back_pressed + 1000 &gt; System.currentTimeMillis()){
           new AlertDialog.Builder(this)
              .setIcon(R.drawable.ic_launcher)
              .setTitle("Esmalteria Cariúcha")
              .setMessage("Sair do Sistema?")
              .setPositiveButton("Sim", new DialogInterface.OnClickListener()
              {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      finish();    
                  }
  
              })
              .setNegativeButton("Não", null)
              .show();  
          }
          else{
              if(webview.canGoBack()){
                  webview.goBack();
              }
          }
          back_pressed = System.currentTimeMillis();
  }
  </code></pre>