title: nested AsyncTask and onPostExecute
body: <p>I am using a <code>AsyncTask</code> (1) in another <code>AsyncTask</code> (2).
  AsyncTask 1 fetches online user data, counts the number of entries in the response and for each entry, in <code>onPostExecute</code> displays a username and runs a new AsyncTask (2) to fetch a image from a server and load it into a <code>ImageView</code>. This all happens in <code>onPostExecute</code>. 
  This is working flawlessly, the user data is fetched and shown, and the images are shown one by one for each entry.</p>
  
  <p>However, the itteration through the array and the updating of the <code>TextView</code> in <code>AsyncTask</code> 1's <code>onPostExecute</code> happens so fast, it basically only shows the last user name in the array, the other ones are loaded, but impossible to detect with the human eye :)</p>
  
  <p>Meanwhile, <code>AsyncTask</code> 2 is still fetching images from online, and showing profile images for the wrong users. 
  The problem I have here obviously, is these 2 need to be in sync.
  So I thought I just wait for the output in <code>AsyncTask</code> 2 with the <code>get()</code> method, but now nothing is updated at all anymore, no <code>TextView</code>...this is unexpected behaviour for me.</p>
  
  <p>So, the question is how to sync the 2 <code>AsyncTask</code>s?</p>
  
  <p>bit of code to clarify, if it's still needed</p>
  
  <pre><code>    //instantiate first AsyncTask
      new AsyncRequest().execute(bundle);
  
      private class AsyncRequest extends AsyncTask&lt;Bundle, Void, String&gt; {
      protected String doInBackground(Bundle... bundle) {
          String data = null;
          try {
              data = request(null, bundle[0]); //request the data
              return data;
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return data;
      }// end method
  
      protected void onPostExecute(String response) {
          JSONArray data = null;
          try {
              JSONObject response2 = Util.parseJson(response);
              data        = response2.optJSONArray("data");
              int amount  = data.length();
              TextView s1 = (TextView) findViewById(R.id.some_id);
              s1.setText("" + amount); //displays number of items
  
              //display the data
              for(int i=0; i&lt;amount; i++){
                  String email        = "";
                  String id           = "";
                  JSONObject json_obj = data.getJSONObject(i);
                  Log.d("JSONObject ", ""+json_obj);
                  String name         = json_obj.getString("name");
                  if (json_obj.has("email")){
                      email           = json_obj.getString("email");
                  }
                  if (json_obj.has("id")){
                      id          = json_obj.getString("id");
                  }
                  String picture  = "http://www.domain.com/"+id+"/picture";
                  TextView s2     = (TextView) findViewById(R.id.name_placeholder);
                  s2.setText(name);
                  //here we do a new AsynTask for each entry and wait until the data is fetched
                  new DownloadProfileImageTask().execute(picture, name).get(); 
              }
          } catch (JSONException e) {
              e.printStackTrace();
          } catch (InterruptedException e) {
              e.printStackTrace();
          } catch (ExecutionException e) {
              e.printStackTrace();
          }
      }// end method
  </code></pre>