compat Async Task Execute - Android java.lang

Android examples for java.lang:Thread

Description

compat Async Task Execute

Demo Code


//package com.java2s;
import android.os.AsyncTask;

public class Main {
    public static final boolean IS_OLD_ASYNC_TASK = android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB;

    public static void compatAsyncTaskExecute(AsyncTask<Void, ?, ?> task) {
        if (IS_OLD_ASYNC_TASK) {
            task.execute();//from  w w w .ja va  2 s. co m
        } else {
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    }
}

Related Tutorials