So, in my Dialog, I have a button which starts an Asynctask downloader to get some file from my server; and that works just fine. However, I want to dismiss my current Dialog and display the ProgressDialog on button clicked. How would I approach this problem?

At the moment, if I click on the button (an element inside my Dialog) the whole UI get froze while the downloader downloading the file from the server. Once the downloader finished its task then the progress dialog will then get shown.

My code looks something like this

```
MainActivity{

    Dialog dialog;
    ProgressDialog progress;

    onCreate(){
        dialog = new Dialog(this);
        progress = new ProgressDialog(this);
        dialog.setContentView(Some View Resource With My Button);
        someMethod();
        dialog.show();
    }

    someMethod(){
        Button button = (Button) dialog.findViewById(resource of button);
        button.setOnClickListener(new OnClickListener(){

            onClick(){
                dialog.dismiss();
                progress.show();
                new DownloaderAsyncTask(progress).execute().get();
            }

                    //go to another activity when download finished

        });
    }

    private class DownloaderAsyncTask extends AsyncTask<Void, Void, Void>{

        ProgressDialog progress;

        DownloaderAsyncTask(ProgressDialog progress){
            this.progress = progress;
        }

        doInBackGround(){
            //Downloading
        }

        onPostExecute(){
            //Kill connection
            this.progress.dismiss();
        }

    }

}

```

Thanks. Please let me know if you guys need any additional information.