corrected a bug where the activity finishes before the dialog is dismissed