title: Calling async tasks one after the other for web service calls by passing values causing App failure
body: <p>I am using multiple spinner classes in my android app like country,state,city.</p>
  
  <blockquote>
    <p>On change of country spinner, state has to be loaded and on change of
    state ,city has to be loaded</p>
  </blockquote>
  
  <p>.Since I am making <strong>REST</strong> call to load the combos, I need to go with AsyncTask tasks.</p>
  
  <p>How to call asysnc tasks one after other since I need to pass some value from
  Async Task1 to Async Task 2.</p>
  
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_load_location); 
          runMultipleAsyncTask();
  
  
      }
      private void runMultipleAsyncTask() // Run Multiple Async Task
      {
         LoadCountryJSON asyncTask = new LoadCountryJSON (); // First
          if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) // Above Api Level 13
          {
              asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
          }
          else // Below Api Level 13
          {
              asyncTask.execute();
          }
          LoadStateJSON asyncTask2 = new LoadStateJSON (); // Second
          if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB)// Above Api Level 13
          {
              asyncTask2.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
          }
          else // Below Api Level 13
          {
              asyncTask2.execute();
          }
          LoadCityJSON asyncTask3 = new LoadCityJSON (); // Third
          if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB)// Above Api Level 13
          {
              asyncTask3.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
          }
          else // Below Api Level 13
          {
              asyncTask3.execute();
          }
      }
  </code></pre>
  
  <p>I have gone through following links but it didn't help</p>
  
  <p><a href="http://blogs.innovationm.com/multiple-asynctask-in-android/" rel="nofollow noreferrer">http://blogs.innovationm.com/multiple-asynctask-in-android/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11010359/two-different-asynctasks-execute-at-the-same-time">Two different AsyncTasks execute at the same time</a></p>