Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: showing a progress dialog

I have looked at the Android API and other posts here on stackoverflow, but have not been able to figure this out.

My app downloads files to the sd card. I would like to pop a "loading..." dialog while the file is downloading and then have it disappear when the download is finished. This is what i came up with using the android API:

ProgressDialog pd = ProgressDialog.show(this,"","Loading. Please wait...",true);

//download file

pd.cancel();

however the dialog doesn't actually show. when i debug it, it claims that it is showing, but it is obviously not on the screen.

what can i do?

like image 759
mtmurdock Avatar asked Jun 10 '10 18:06

mtmurdock


1 Answers

You have to run the download code into a separated Thread. The easy way is to use AsyncTask

Look also this article on how to use it

like image 136
Francesco Laurita Avatar answered Sep 20 '22 17:09

Francesco Laurita