Null-ignoring AsyncTask stopper method. - Android android.os

Android examples for android.os:AsyncTask

Description

Null-ignoring AsyncTask stopper method.

Demo Code

/*//ww w  . j a  v  a  2s.c om
 * AsyncUtils.java: First version written on 16. Feb. 2011.
 * 
 * This file is subject to the terms and conditions defined in
 * file 'licence.txt', which is part of this source code package.
 */
import android.app.Dialog;
import android.os.AsyncTask;

public class Main{
    /**
     * Null-ignoring <code>AsyncTask</code> stopper method.
     */
    public static void stopAsyncTaskQuietly(
            final AsyncTask<?, ?, ?> asyncTask) {
        if (null != asyncTask) {
            asyncTask.cancel(true);
        }
    }
    public static void stopAsyncTaskQuietly(
            final AbstractProgressAsyncTask<?> asyncTask) {
        if (null != asyncTask) {
            asyncTask.cancel();
        }
    }
}

Related Tutorials