Java tutorial
//package com.java2s; import android.os.AsyncTask; public class Main { public static boolean cancelTask(AsyncTask<?, ?, ?> paramAsyncTask) { if (!isAsynctaskFinished(paramAsyncTask)) return paramAsyncTask.cancel(true); return false; } public static boolean isAsynctaskFinished(AsyncTask<?, ?, ?> paramAsyncTask) { return (paramAsyncTask == null) || (paramAsyncTask.getStatus() == AsyncTask.Status.FINISHED); } }