Question: I need to do some work on the UI thread, specifically setting up some views, etc. - this can't be done in a background thread. The process is invoked on a button click and takes about a second or so to complete - without a progress dialog it looks as if the app is frozen. I use progress dialog with `AsynTask`s in several places and it works fine - however here I'm struggling.

I started with simple:

```
showDialog(DIALOG_PLEASE_WAIT);
viewInfo.setFromGuide(true);          //this method just sets a variable
viewInfo.setVenue(venue);             //this method does a lot of UI manipulation and takes a second or so
showScreen(VIEW_INFO);                //this method shows the corresponding view in ViewFlipper
dismissDialog(DIALOG_PLEASE_WAIT);

```

However the dialog would not show (sort of expected, as this is all on UI thread.

Then I changed the code to this:

```
Handler hnd = new Handler() {
    @Override
    handleMessage(Message m) {
        viewInfo.setFromGuide(true);
        viewInfo.setVenue(venue);
        showScreen(VIEW_INFO);
        dismissDialog(DIALOG_PLEASE_WAIT);
    }
}
showDialog(DIALOG_PLEASE_WAIT);
new Thread() {
    public void run() {
       hnd.sendEmptyMessage(0);
    }
}.start();

```

This still doesn't show the dialog - naturally, the UI work in `handleMessage` is still done on the UI thread. So, what can I do to show the progress dialog?

Answer: 
If it takes really takes `a second or so to complete` than maybe you can just use a simple Toast notification with a message like "Please wait"
as you are using `AsyncTask` you can override `onProgressUpdate` which is called when ever you call `publishProgress()` from inside the `doInBackGround` so you can publish your results smoothly while working in background because, `onProgressUpdate` works on the UI thread.