Back Button Is Not Working ,while Progressdialog Is Running
Solution 1:
You need to override back button event. You can do this as:
@OverridepublicbooleanonKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && progressDialog.isShowing()) {
Log.d(this.getClass().getName(), "back button pressed");//write your own logic here, Whatever you want to do
}
returnsuper.onKeyDown(keyCode, event);
}
Solution 2:
Well, I had the same issue. The simplest method that worked for me is using progressDialog.setCancelable(true).. This declares whether the dialog is cancelable by hitting the back key.. Try it and let me know if it works for you or not. Good luck
Solution 3:
Similar issue , When progressDialog.setCancelable(true) is set then hitting back button does not execute code written in back button code but just cancels the progress dialog..Hitting the key again works.
i want to cancel the progress dialog and execute some piece of code together which is not working. Clicking back button twice does not make sense to me.
Solution 4:
You can use progressDialog.setCancelable(true)
and then use progressDialog.setOnCancelListener()
to provide the OnCancelListener
to execute your code to be executed onCancel()
.
See the Android documentation on Dialogs.
Post a Comment for "Back Button Is Not Working ,while Progressdialog Is Running"