dialog - on key event executing multiple times android -


i showing dialog in activity in application.when detecting on key event in dialog executing multiple times.i have go previous activity without dismiss dialog.can have idea it?

 @override         public boolean onkey(dialoginterface arg0, int keycode,                              keyevent event) {              if (keycode == keyevent.keycode_back && isclicked==false) {                  if (globalapp.activity != null) {                      log.i("activity",""+globalapp.activity);                     isclicked=true;                      globalapp.activity.onbackpressed();                      dialog_footer.dismiss();                 }              }              return true;         } 

it called twice, once pressing key, , second time releasing it. try this:

    @override     public boolean onkey(dialoginterface arg0, int keycode,                          keyevent event) {          if (event.getaction()!=keyevent.action_down) return true;          if (keycode == keyevent.keycode_back && isclicked==false) {              if (globalapp.activity != null) {                  log.i("activity",""+globalapp.activity);                 isclicked=true;                  globalapp.activity.onbackpressed();                  dialog_footer.dismiss();             }          }          return true;     } 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -