android - Close progress dialog failed -
i'm trying close progressdialog after couple of seconds (only visual theme) no success. dismiss dialog, expect enter key clicked, dialog visible when click done in event. here code using:
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) && (keycode == keyevent.keycode_enter)) {           if (pdialog.isshowing()) {           pdialog.dismiss();       }        intent intent = new intent(validacionbluetooth.this, validador.class);       startactivity(intent); } edit
i message prevents dialogue closed , continue running code.
01-27 16:11:31.041: w/viewrootimpl(6633): cancelling event due 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 } 
create class method outside of keylistener. inside key listener, dismiss progress dialog.
lectura.setonkeylistener(new onkeylistener() {     public boolean onkey(view view, int keycode, keyevent keyevent) {     pdialog = new progressdialog(validacionbluetooth.this);     pdialog.setmessage("sincronizando...");     pdialog.setcancelable(false);     pdialog.show()      if ((keyevent.getaction() == keyevent.action_down) && (keycode == keyevent.keycode_enter)) {         if (pdialog.isshowing()) {             dismissdialog();         }          intent intent = new intent(validacionbluetooth.this, validador.class);         startactivity(intent);     } }  private void dismissdialog() {      pdialog.dismiss(); } 
Comments
Post a Comment