title: Close progress dialog failed
body: <p>I'm trying to close a <code>ProgressDialog</code> after a couple of seconds (only visual theme) but with no success. To dismiss the dialog, I expect the Enter key to be clicked, but the dialog is always visible even when the click is done in the event. Here is the code I am using:</p>
  
  <pre><code>lectura.setOnKeyListener(new OnKeyListener() {
     public boolean onKey(View view, int keyCode, KeyEvent keyevent) {
        if(pDialog == null) {
             pDialog = new ProgressDialog(ValidacionBlueTooth.this);
             pDialog.setMessage("Sincronizando...");
             pDialog.setCancelable(false);
             pDialog.show();
        }
  
        if ((keyevent.getAction() == KeyEvent.ACTION_DOWN) &amp;&amp; (keyCode == KeyEvent.KEYCODE_ENTER)) {
            if (pDialog.isShowing()) {
            pDialog.dismiss();
        }
  
        Intent intent = new Intent(ValidacionBlueTooth.this, Validador.class);
        startActivity(intent);
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I get this message that prevents the dialogue is closed and also to continue running the code.</p>
  
  <pre><code>01-27 16:11:31.041: W/ViewRootImpl(6633): Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_3, scanCode=4, metaState=0, flags=0x28, repeatCount=0, eventTime=81457114, downTime=81457113, deviceId=36, source=0x101 }
  </code></pre>