title: How to show same progress bar for loading data from internet and displaying content on UI
body: <p>I am creating an app in which I have to fetch some data from Internet and show it to user on UI.
  I have create an progress bar in <code>AsyncTask</code> <code>onPreExecute()</code> method and in <code>onPostExecute()</code> method I have passed all data to another Activity and startActivty. Then I dismiss the progress dialog. But, it not  fine.
  As when the second <code>activity</code> loaded data on UI in <code>onCreate</code> method then ProgressBar hangs.
  How do I solve this problem.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>@Override
      protected void onPreExecute() {
          proDialog = new ProgressDialog(mContext);
          proDialog.setTitle("Support Manager");
          proDialog.setMessage("Logging in ...");
          proDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
          proDialog.setIcon(R.drawable.ic_launcher);
          proDialog.show();
          super.onPreExecute();
      }
  
  
      @Override
      protected RepresentativeData doInBackground(String... params) {
          JSONObject result = null;
  
          try {
              result = client.reprentativeDetailNode(params[0]);
              LoginJsonParsing loginJsonParsing = new LoginJsonParsing();
              Details = loginJsonParsing
                      .Details(result);
          } catch (ClientProtocolException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return Details;
      }
  
      @Override
      protected void onPostExecute(Data result) {
  
          Intent secActivity = new Intent(mContext,YourRepresentative.class);
          secAcitivity.putExtra("detail", result);
  
          mContext.startActivity(secActivity);
          proDialog.dismiss();
          super.onPostExecute(result);
      }
  </code></pre>