title: Progress Bar not showing in AsyncTask onPreExecute()
body: <p>My current project involves downloading data from a server - this is taking around 20s so during this time I want to display a progress bar so the user knows what is going on. The downloading task is executed inside DownloadWebpageTask (AsyncTask) and I'm setting the progress bar visibility in the preExecute() but it isn't showing up. I've looked through a whole load of questions on here and I still can't get this to work. If I don't hide the progress bar in onPostExecute() I can see what is happening - even though I set progBar.setVisibility(0) in onPreExecute() the bar is not actually showing up until after doInBackground. I tried setting a TextView in onPreExecute as well to see if it's just the progress bar not working but this also failed.</p>
  
  <p>Please can someone help me out here, I'm completely stuck!!</p>
  
  <p>This calls my AsyncTask:</p>
  
  <pre><code>public void getDTCs(View view) throws URISyntaxException{       
  
          DtcListSingleton.getInstance().setData(null);
          status = "DTC Parsing Not Attempted";
          noDTCs = 0;
  
          TextView listTitle = (TextView) findViewById(R.id.DTCtitle);
          String newTitle = "Waiting for DTCs";
          listTitle.setText(newTitle);
  
  
          String stringURL = "http://192.168.1.129";
          //Check connection
          ConnectivityManager cMgr = (ConnectivityManager)getSystemService(this.CONNECTIVITY_SERVICE);
          NetworkInfo netInf = cMgr.getActiveNetworkInfo();
  
          // If connected to network carry on with DTC request
          if(netInf != null &amp;&amp; netInf.isConnected()){
  
              //Download the web page as an InputStream
              new DownloadWebpageTask().execute(stringURL);
  </code></pre>
  
  <p>And this is my AsyncTask:</p>
  
  <pre><code>private class DownloadWebpageTask extends AsyncTask&lt;String,Void,String&gt;{
          @Override 
          protected void onPreExecute(){
              super.onPreExecute();
              progBar = (ProgressBar)findViewById(R.id.loadingDTCs);
              progBar.setVisibility(0);
              TextView title = (TextView)findViewById(R.id.DTCtitle);
              title.setText("Loading DTCs");
          }
          @Override
          protected String doInBackground(String...urls){
              //params[0] is the url
              try{
                  return downloadUrl(urls[0]);
              }
              catch(IOException e){
                  return "Unable to retreieve web page. URL may be invalid.";
              } 
  
              // DELETE if overcome client.print delay
              catch (InterruptedException e) {
                  e.printStackTrace();
                  return "Interrupted Exception from Delaying inputstream"; 
              }
          }
          @Override
          protected void onPostExecute(String result){
  
              AlertDialog.Builder resultURL = new AlertDialog.Builder(ActionReadDTCs.this);
  
              resultURL.setTitle("Result of DownloadWebPageTask")
              .setMessage(result)
  
              .setPositiveButton("OK", new DialogInterface.OnClickListener(){
                  public void onClick(DialogInterface dialog, int id){
                      progBar = (ProgressBar)findViewById(R.id.loadingDTCs);
                      progBar.setVisibility(8);
                      return;
                  }
              })
  
              .show();
          }
      }
  </code></pre>