execute AsyncTask On Executor - Android android.os

Android examples for android.os:AsyncTask

Description

execute AsyncTask On Executor

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.os.AsyncTask;
import android.os.Build;

public class Main {
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    // API 11//from w  ww.j a  va 2  s  .  c om
    public static void executeOnExecutor(
            AsyncTask<Object, Void, Object> asyncTask) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        else
            asyncTask.execute();
    }
}

Related Tutorials