Reputation: 105
I have an application that needs to show the initializing progress of a sensor. my progress dialog is set to cancelable(false);
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("Please follow instructions");
progressDialog.setMessage("Initializing reader");
progressDialog.setCancelable(false);
progressDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "Enter manually", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
returnResult(RESULT_START_MANUAL_INPUT);
}
});
progressDialog.show();
But i DO need it to be cancelable when pressing the back button. and it should not be cancelable by pressing the screen. how can i do this?
thanks in advance!
Upvotes: 1
Views: 4133
Reputation: 7321
Just add these two lines of code:
progressDialog.setCancelable(true) // to cancel the progressbar when you click on the back button
progressDialog.setCanceledOnTouchOutside(false) // to prevent closing when you touch to the screen.
Upvotes: 3
Reputation: 3520
Just replace
progressDialog.setCancelable(false);
to
progressDialog.setCanceledOnTouchOutside(false);
Upvotes: 14