Strange behavior of ProgressDialog's key listener in Android -


i wrtie small program test progressdialog in android.

    dialoginterface.onkeylistener dialogkey = new dialoginterface.onkeylistener() {         public boolean onkey(dialoginterface arg0, int arg1, keyevent arg2) {             switch(arg1) {             case keyevent.keycode_volume_down:                 log.i("spinner key", "key volume down");                             log.i("spinner key", "" + arg0.tostring());                 return true;             case keyevent.keycode_volume_up:                     log.i("spinner key", "key volume up");                              log.i("spinner key", "" + arg0.tostring());                 return true;                             default:                     break;             }             return true;         }     };                       this.mypdialog = new progressdialog(sensordefenceactivity.this);                      this.mypdialog.setprogressstyle(progressdialog.style_spinner);         this.mypdialog.settitle("count");         this.mypdialog.setindeterminate(false);         this.mypdialog.setmessage(this.start + "");         this.mypdialog.setcancelable(false);         this.mypdialog.setcanceledontouchoutside(false);         this.mypdialog.setbutton("cancel", new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int i)             {                 dialog.cancel();             }         });          mypdialog.setonkeylistener(dialogkey);         mypdialog.show();            mypdialog.getwindow().settype(windowmanager.layoutparams.type_keyguard);  

when dialog shows, press 1 of volume keys. same key press notification in logcat twice!

06-08 17:54:07.130: i/spinner key(11636): key volume 06-08 17:54:07.130: i/spinner key(11636): android.app.progressdialog@402bdd78 06-08 17:54:07.260: i/spinner key(11636): key volume 06-08 17:54:07.260: i/spinner key(11636): android.app.progressdialog@402bdd78 06-08 17:54:11.320: i/spinner key(11636): key volume down 06-08 17:54:11.320: i/spinner key(11636): android.app.progressdialog@402bdd78 06-08 17:54:11.530: i/spinner key(11636): key volume down 06-08 17:54:11.530: i/spinner key(11636): android.app.progressdialog@402bdd78 

i promise press time short can't trigger same key press message twice.

onkey executed both keyevent.action_up , keyevent.action_down. (ie arg2)

execute code 1 of them. think action_down should one.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -