Java tutorial
//package com.java2s; import android.os.AsyncTask; public class Main { /** * Cancels asynchronous tasks immediately. * @param tasks array of asynchronous tasks */ public static void cancelTasks(AsyncTask<?, ?, ?>... tasks) { if (null != tasks) { for (AsyncTask<?, ?, ?> task : tasks) { if (null != task) task.cancel(true); } } } }