I am trying to display a progress dialog during downloading of data.
Right now, this is what I have:
final ProgressDialog pd = ProgressDialog.show(this, "Updating", "Loading...");
Thread td = new Thread(new Runnable(){
public void run(){
//time consuming download
pd.dismiss();
}
});
td.start(); // start the thread and use join to wait for it to return
td.join(); //wrapped in try catch not shown here
I don't need progress updates from the download, and the app shouldn't do anything else until the data is downloaded, that's why I use join - so it'll wait for the download to finish.
The result I'm getting is
- Push button
- UI freezes
- progress dialog flashes on and off, download is done
what I need is
- Push button
- progress dialog shows
- progress dialog turns off, download is done.
Any idea why it's not showing right away, and instead flashing on and off when it is done?