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
Post a Comment