I\'ve 2 ASyncTasks, one retrieves a value from an httpPost and the other update some elements of the UI (including an listview). The problem is that since both ASyncTasks share
A slightly more general way to do this is to put two helper methods in a utility class like so:
class Utils {
@SuppressLint("NewApi")
public static > void execute(T task, P... params) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
} else {
task.execute(params);
}
}
}
Then you can execute tasks with Utils.execute(mytask)
or Utils.execute(mytask, params)
and it will take care of executing them in parallel.