traveller traveller - 2 months ago 11
Android Question

progress dialog will not show up

I want by pressing a button to show the progress dialog and dismiss it when the function is done. My code is below and although it's very easy for an unknown reason to me it won't run.

final Button button = (Button) findViewById(;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setTitle("Please Wait..");
progressDialog.setMessage("Preparing to download ...");;




Two possibilities i can think of why it is not working for you:

  1. The method "bringData()" is executed on the ui thread. So the ui thread is doing work (executing bringData) and won't redraw the ui. Afterwards you dismiss the dialog and it seems like the Dialog is not showing.

  2. In the method "bringData()", you start a background thread. In this scenario you would show the Dialog and dismissing it directly.

Since you are using volley, which you mentioned in your comment, you have to dismiss the dialog when your GET Request has finished. Therefore you have dismiss the dialog in the callback method.