Android examples for android.os:AsyncTask
execute AsyncTask
//package com.java2s; import android.annotation.SuppressLint; import android.os.AsyncTask; import android.os.Build; public class Main { @SuppressLint("NewApi") public static void execute(AsyncTask<Void, Void, Void> task) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {// w ww . j a v a 2 s . c o m task.execute(); } } @SuppressLint("NewApi") public static void execute(AsyncTask<Boolean, Void, ?> task, Boolean params) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params); } else { task.execute(params); } } }