Reputation: 17185
I have an activity which needs to make two remote server calls. The first is simple and happens when the page loads and I just make a call to fetch some data and show it...no problem.
The problem happens in the second call because once I call sendFeedback, it tries to execute the task, but the doInBackground() method was written for the original call, and thus the parameters won't work, and also the function that is called when the data is returned from the remote call won't be the same for both calls.
What is commonly done in a situation that I am facing where I need to make two different remote calls from one Activity?
Thanks!
Upvotes: 1
Views: 1179
Reputation: 654
Just create 2 AsyncTask where you need them.
new AsyncTask<String, Void, Object>() {
@Override
protected Object doInBackground(String... params) {
// put task here
}
@Override
protected void onPostExecute(Object result) {
super.onPostExecute(result);
}
};
Upvotes: 2
Reputation: 3394
I couldn't quite follow what you want, but I think you're saying you want to make two asynchronous calls in sequence with the second depending on the first.
If my understanding is correct, start the second AsyncTask
from the onPostExecute()
method of the first.
Upvotes: 2