title: Show progress bar while downloading data using Async Task from one activity to another
body: <p>I am trying to load data into object list using Async task using tast.execute(parameters).get() , but when i am using that It doesnot allow the progress bar to show. It gets stuck for some time and then it populates that data. </p>
  
  <p>This is my Async Task</p>
  
  <pre><code>public class GetAllCars extends AsyncTask&lt;String, Void, List&lt;Car&gt;&gt; {
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
      }
  
      @Override
      protected void onPostExecute(List&lt;Car&gt; result) {
          super.onPostExecute(result);
  
      }
  
      @Override
      protected List&lt;Car&gt; doInBackground(String... params) {
          // TODO Auto-generated method stub
          List&lt;Car&gt; cars = new ArrayList&lt;Car&gt;();
          try {
              String result = HttpClient.SendHttpGet(UrlUtils.BASE_URL
                      + UrlUtils.GET_LOCALCARS + params[0]);
              ResponseParser parser = new ResponseParser();
  
              cars = parser.parseCar(result);
          } catch (NumberFormatException e) {
              e.printStackTrace();
          } catch (JSONException e) {
              e.printStackTrace();
          }
          return cars;
      }
  }
  </code></pre>
  
  <p>This is Activity from which async task is called.</p>
  
  <pre><code>public class ViewCars extends ActionBarActivity {
  
      ListView mainlist;
      List&lt;Car&gt; list;
      Bitmap bit;
      ImageView cImage;
      Intent intent;
  
      private ProgressDialog progress;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_view_cars);
          progress= new ProgressDialog(this);
          Intent i = getIntent();
          String param = Integer.toString(Integer.parseInt(i.getExtras()
                  .getString("Location")) + 1);
  
          try {
              final GetAllCars task = new GetAllCars();
              task.execute(param);
              list = task.get();
  
              mainlist = (ListView) findViewById(R.id.mainlist);
              mainlist.setAdapter(new carListAdapter(this));
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (ExecutionException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (NumberFormatException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          mainlist.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
  
                  int carId = (int) id;
                  Car car = list.get(carId);
                  intent = new Intent(ViewCars.this, ViewCar.class);
                  intent.putExtra("CarId", car.getCarId());
                  startActivity(intent);
              }
  
          });
      }
  
      public void open(View view){
          progress.setMessage("Downloading");
          progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
          progress.setIndeterminate(true);
          progress.show();
      }
  
      class carListAdapter extends BaseAdapter {
  
          Context context;
  
          carListAdapter(Context c) throws InterruptedException,
                  ExecutionException, NumberFormatException, JSONException {
              context = c;
          }
  
          @Override
          public int getCount() {
              // TODO Auto-generated method stub
              return list.size();
          }
  
          @Override
          public Object getItem(int arg0) {
              // TODO Auto-generated method stub
              return list.size();
          }
  
          @Override
          public long getItemId(int arg0) {
              // TODO Auto-generated method stub
              return arg0;
          }
  
          @Override
          public View getView(int arg0, View arg1, ViewGroup arg2) {
              // TODO Auto-generated method stub
              LayoutInflater inflater = (LayoutInflater) context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View row = inflater.inflate(R.layout.viewcars, arg2, false);
              TextView cName = (TextView) row.findViewById(R.id.cName);
              TextView cCapacity = (TextView) row.findViewById(R.id.cCapacity);
              cImage = (ImageView) row.findViewById(R.id.cPoster);
  
              Car c = list.get(arg0);
              cName.setText(c.getName().toString());
              cCapacity.setText(Integer.toString(c.getCapacity()));
              /*
               * ImageLoader imgLoader = new ImageLoader(getApplicationContext());
               * imgLoader.DisplayImage(UrlUtils.GET_CAR_IMAGE+c.getCarImage1(),
               * R.drawable.logo, cImage);
               */
              ImageDownloader id = new ImageDownloader();
              try {
                  bit = id.execute(UrlUtils.GET_CAR_IMAGE + c.getCarImage1())
                          .get();
              } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (ExecutionException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              cImage.setImageBitmap(bit);
              return row;
          }
  
      }
  }
  </code></pre>
  
  <p>This is the First activity where the Second Activity is called</p>
  
  <pre><code>public class LocalActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_local);
  
  public void findTaxi(View v){
  
          Intent intent = new Intent(LocalActivity.this,ViewCars.class);
          intent.putExtra("Location",""+spinnerCity.getSelectedItemId());
          intent.putExtra("Date", btnChooseDate.getText().toString());
          startActivity(intent);
      }
  }
  </code></pre>
  
  <p>I want to implement a progress bar to show the user that the data is been loaded. Kindly help me out to resolve this problem...</p>