Reputation: 104
I'm trying to run two AsyncTasks at the same time. However, only the first gets executed. And no data returned from second service. When refresh it second time I get data from service hoe to resolve the issue?? Here is my code
new MyClass().execute("Main");
> Class is
private class MyClass extends AsyncTask<Object, Void, String> {
> here i am using pre post and do in background methods
}
Upvotes: 0
Views: 134
Reputation: 459
This allows for parallel execution on all android versions with API 4+ (Android 1.6+):
@TargetApi(Build.VERSION_CODES.HONEYCOMB) // API 11
void startMyTask(AsyncTask asyncTask) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
else
asyncTask.execute(params);
}
Upvotes: 1