Showing ProgressDialog in an Activity

Posted on Updated on

In some cases we need to wait until some long process is carried out in an activity. In this case its a good practice to notify user that the operation is in progress and also for preventing the UI from freezing. For this purpose android API has got classes such as ProgressDialog and ProgressBar. Here I am going to explain one of the method that is how to use ProgressDialog in an Activity.

The syntax for ProgressDialog is context, CharSequence title, CharSequence message);

Now we need to create thread for the complex operation. The entire code is shown below

private ProgressDialog progressDialog;, "Please Wait", "Executing complex operation....");
new Thread()
public void run()
//add ur complex function here
catch(Exception e)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s