cannot display progress bar at the time of loading another Activity in Android

This may be a simple question but i am a beginner ,i need your suggestion on this. i have two Activities A1 and A2 .When i click the image on A1 screen i have to display progress bar until A2 screen appears(A2 activity has huge task to do).I tried

 image.setOnClickListener(new ImageView.OnClickListener() {

            public void onClick(View v)

             myProgressDialog =,     
                        "Please wait...", "Loading...", true);

              new Thread() {
                   public void run() {

                        Intent i = new Intent(A1.this,.A2.class);

                        } catch (Exception e) {  }
                        // Dismiss the Dialog


This couldn't display progress bar .I know that i am making a mistake but i couldn't figure out


Your best bet is to show the progress dialog in the A2 activity. Once you start an Activity, the previous activity goes into the background, so the progress dialog wouldn't display anyway.

First of all , the progress dialog needs to be called on a separate thread . Use the AsyncTask<> to display the dialog and at the same time perform some operation in the background . A sample code might be something like this

class hello extends AsyncTask<Void,Void,Void>
       ProgressDialog dialog=null;
       Intent i;

   protected void onPreExecute() 


    protected void onPostExecute(Void result) 

    protected Void doInBackground(Void... params) 
        i = new Intent(A1.this,.A2.class);
                    return null;


 ? Is there a black progress bar to be visible on a white background?
 ? How to remove progress bar number at the bottom part of the progress bar?
 ? Vertical progress bar in android
 ? Custom indeterminate progress bar
 ? Progress bar inconvertable types; cannot cast error
 ? Remove progress bar from published document in MATLAB
 ? What is the basic idea behind programming a progress/status bar in MATLAB?
 ? Text progress bar in Matlab
 ? MATLAB update waitbar
 ? xlsread and waitbar MATLAB