Skip to content

Instantly share code, notes, and snippets.

@ikew0ng
Created January 16, 2013 14:11
Show Gist options
  • Save ikew0ng/4547352 to your computer and use it in GitHub Desktop.
Save ikew0ng/4547352 to your computer and use it in GitHub Desktop.
executeAsyncTask
/**
* 使用{@link AsyncTask.THREAD_POOL_EXECUTOR} 执行AsyncTask 这样可以避免android
* 4.0以上系统 每次只执行一个 asyncTask
*
* @param task
* @param params
*/
public static <Params, Progress, Result> void executeAsyncTask(
AsyncTask<Params, Progress, Result> task, Params... params) {
if (VERSION.SDK_INT >= 11) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
} else {
task.execute(params);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment