Example usage for android.os AsyncTask execute

List of usage examples for android.os AsyncTask execute

Introduction

In this page you can find the example usage for android.os AsyncTask execute.

Prototype

@MainThread
public static void execute(Runnable runnable) 

Source Link

Document

Convenience version of #execute(Object) for use with a simple Runnable object.

Usage

From source file:Main.java

public static <T> void executeAsyncTask(AsyncTask<T, ?, ?> task, T... params) {
    task.execute(params);
}

From source file:Main.java

public static <Param> void executeInParallel(AsyncTask<Param, ?, ?> task, Param... params) {
    if (Build.VERSION.SDK_INT < 11) {
        task.execute(params);
    } else {/*from w  ww  . j a  v a  2  s  .  c o  m*/
        try {
            sMethodExecuteOnExecutor.invoke(task, sExecutor, params);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:Main.java

public static <A, B, C> AsyncTask<A, B, C> execute(AsyncTask<A, B, C> task, A... args) {
    return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? executeHoneycomb(task, args)
            : task.execute(args);
}

From source file:Main.java

@SafeVarargs
public static <T> void executeAsyncTask(AsyncTask<T, ?, ?> task, T... params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        honeycombExecuteAsyncTask(task, params);
    } else {//from w w w .j  ava2s . com
        task.execute(params);
    }
}

From source file:Main.java

public static void execute(AsyncTask task, Object... args) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args);
    } else {/*from w  ww. j  a  v  a2 s.  c o m*/
        task.execute(args);
    }
}

From source file:Main.java

/**
 * Execute task./*from  w ww.j  a  va2 s .  c  om*/
 *
 * @param theTask the the task
 */
@SuppressLint({ "NewApi" })
public static void executeTask(AsyncTask theTask) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        theTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
    else
        theTask.execute((Void[]) null);
}

From source file:Main.java

public static <T> void StartAsyncTask(AsyncTask asyncTask, T... params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    else//from   ww  w  .  ja  va2  s.c o m
        asyncTask.execute(params);
}

From source file:Main.java

public static void startMyTask(AsyncTask asyncTask, Object... params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    else/*from  w  w w  .  j a va2  s.c  o m*/
        asyncTask.execute(params);
}

From source file:Main.java

public static void start(AsyncTask task) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[] {});
    } else {/*from w  w w. j av a 2  s.  com*/
        task.execute(new Void[] {});
    }
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static <T> void executeTask(AsyncTask<T, ?, ?> task, T... params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    } else {// ww w  . ja  v a 2s  .c o m
        task.execute(params);
    }
}