How to create Progress Dialog in Android Application?

shiteru picture shiteru · Jul 8, 2013 · Viewed 22.9k times · Source

I am developing the application to receive some data from the internet while receiving the data I want to show the "Progress Dialog". I used "AsyncTask" in my application.

The question is how to use it and how to show the percentage like 100%?

Please suggest me and give me some example. Thank you and Sorry for my English.

Answer

shreyas picture shreyas · Jul 8, 2013

To show the prgress dialog you can use the below code

 ProgressDialog dialog = new ProgressDialog(MainActivity.this);
                dialog.setMessage("Your message..");
                dialog.show();

before you call the async task i.e. before new YourTask.execute().

and in the onPostExecute function of the asynctask You can use

 dialog.dismiss();

to dismiss the dialog.