title: Code doesn't execute HttpResponse for second time when called twice
body: <p>I'm doing and app who calls the same method two times and the second time I call the method it doesn't execute the line with HttResponse.</p>
  
  <p>Here is the AsyncTask where everything starts:</p>
  
  <pre><code>private class FetchSubjectsTask extends AsyncTask&lt;String, Void, List&lt;Subject&gt;&gt; {
      private ProgressDialog pd;
      @Override
      protected List&lt;Subject&gt; doInBackground(String... params) {
  
          List&lt;Subject&gt; subjects = null;
          try {
              subjects = api.getMySubjects(params[0]);
  
          } catch (Exception e) {
              e.printStackTrace();
          }
              return subjects; 
      }
  
      @Override
      protected void onPostExecute(List&lt;Subject&gt; result) {
  
          printSubjects(result);
  
          if (pd != null) {
              pd.dismiss();
          }
      }
  }
  </code></pre>
  
  <p>Then I get the subjects through the method getMySubjects which is:</p>
  
  <pre><code>public List&lt;Subject&gt; getMySubjects(String username) {
      List&lt;Subject&gt; subjects = new ArrayList&lt;Subject&gt;();
      java.lang.reflect.Type arrayListType = new TypeToken&lt;ArrayList&lt;Subject&gt;&gt;() {
      }.getType();
      String url = BASE_URL_VM + "users/" + username + "/subjects";
      HttpClient httpClient = WebServiceUtils.getHttpClient();
      try {
          System.out.println("inside try");
          HttpResponse response = httpClient.execute(new HttpGet(url));
          System.out.println("response executed");
          HttpEntity entity = response.getEntity();
          Reader reader = new InputStreamReader(entity.getContent());
          subjects = gson.fromJson(reader, arrayListType);
      } catch (Exception e) {
  
      }
      System.out.println("Array lenght " +subjects.size());
      return subjects;
  }
  </code></pre>
  
  <p>That's the first time HttpResponse executes and I get the "response executed" and "Array lenght 2" which are the number of subjects that user (username) has in the database.</p>
  
  <p>The problem is when in onPostExecute I call the method printSubjects which is:</p>
  
  <pre><code>private void printSubjects(List&lt;Subject&gt; subjects){
      adapter = new SubjectAdapter(this,(ArrayList&lt;Subject&gt;)subjects, (String) getIntent().getExtras().get("username"));
      setListAdapter(adapter);
      adapter.notifyDataSetChanged();
  }
  </code></pre>
  
  <p>This calls the SubjectAdapter which prints the Subjects in a ListView:</p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ViewHolder viewHolder = null;
      if (convertView == null) {  
      convertView = inflater.inflate(R.layout.subject_detail, null);
      viewHolder = new ViewHolder();
      viewHolder.tvsubject = (TextView) convertView
              .findViewById(R.id.tvsubject);
  
      boolean match = api.checkMySubjects(username, data.get(position).getId());
  
      Button addButton = (Button) convertView.findViewById(R.id.bAdd);
      if(match){
          addButton.setText("Delete");
      }else{
          addButton.setText("Add");
      }
  
      String content = data.get(position).getName();
      viewHolder.tvsubject.setText(content);
      }
      return convertView;
  }
  
  private static class ViewHolder {
      TextView tvsubject;
      TextView tvauthor;
  }
  </code></pre>
  
  <p>There I call the method checkMySubjects which calls again getMySubjects to compare.</p>
  
  <pre><code>public boolean checkMySubjects(String username, String id) {
      List&lt;Subject&gt; mySubjects = getMySubjects(username);
      boolean match = false;
      for (Subject s1 : mySubjects) {
          if (s1.getId().equals(id)) {
              match = true;
          }
      }
      return match;
  }
  </code></pre>
  
  <p>But now the method getMySubjects doesn't arrive until "Response executed" and the Array lenght is 0. It only shows "Inside try".
  Why? I'm calling the same method with the same URL but first time I get the 2 subjects in the array and the second time I get nothing because HttResponse doesn't execute.</p>
  
  <p>Thank you!</p>