I am using multiple spinner classes in my android app like country,state,city.
On change of country spinner, state has to be loaded and on change of state ,city has to be loaded
.Since I am making REST call to load the combos, I need to go with AsyncTask tasks.
How to call asysnc tasks one after other since I need to pass some value from Async Task1 to Async Task 2.
@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 >= 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 >= 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 >= Build.VERSION_CODES.HONEYCOMB)// Above Api Level 13
{
asyncTask3.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
else // Below Api Level 13
{
asyncTask3.execute();
}
}
I have gone through following links but it didn't help