How to show a progress bar dialog irrespective of what happens in background UI I have 3 activities interlinked to each other. By clicking an aspect of 1 st activity i will navigate to 2nd one, and on clicking an aspect of second i will go to third. The problem is it's taking a lot of time and the screen freezes. My program is too big to include the AsyncTask. Is there anyway of showing a progress dialog like "please wait" when i navigate from an activity to another. It will be much user friendly than a non-responsive screen.And i mean till the content of the new activity is displayed.

If you move from Activity1 to Activity2 and


*

*your app freezes on Activity1, then why just not have an overlay on each Activity, a simple TextView with match_parent on each side, and some text which initially is set to Visibility.GONE and before you start the next Activity you just set the visibility to Visibility.VISIBLE ? 


You can reset the visibility back to GONE in onStart 
(i.e. when you press back on Activity 2 and come back to Activity 1, on Activity 1's onStart you set the visibility to GONE)


*

*your app freezes on Activity2, then set the TextView to visibile by default in your xml and then set the visibility to GONE once your finish whatever it is that freezes the screen.


I recommend using a simple TextView instead of a ProgressBar as you said that the app freezes, so if it freezes I'm presuming the ProgressBar won't animate itself, so no use in having moving parts for this.

Declare an AsyncTask, then simply display ProgressDialog on preExecute of AsyncTask. Do the time consuming and application freezing things like retrieving data from Link on doInBackground. Do the post Link retrieved works in the onPostExecute of asyncTask and dismiss the `ProgressDialog. AsyncTask runs on a diffrent thread from the main activity and hence the application doesn't freeze.
// ASYNC TASK
    class ClassName extends AsyncTask<String, Void, Integer> {
protected void onPreExecute() {
progress = ProgressDialog.show(context, "", "Loading ...",
false, true);
}

@Override
protected Integer doInBackground(String... params) {
// Your Code
}

protected void onPostExecute(Integer result) {

if (progress != null) {
progress.dismiss();
}
}
    }