execute AsyncTask With Result Bitmap - Android android.graphics

Android examples for android.graphics:Bitmap Operation

Description

execute AsyncTask With Result Bitmap

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Build;

public class Main {
    @SuppressLint("NewApi")
    public static void executeWithResultBitmap(
            AsyncTask<Void, Void, Bitmap> task) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {/*from   w w w. j a  va  2s. c  o  m*/
            task.execute();
        }
    }

    @SuppressLint("NewApi")
    public static void execute(AsyncTask<Void, Void, Void> task) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            task.execute();
        }
    }

    @SuppressLint("NewApi")
    public static void execute(AsyncTask<Boolean, Void, ?> task,
            Boolean params) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
        } else {
            task.execute(params);
        }
    }
}

Related Tutorials