Coder Social home page Coder Social logo

suclike / android-asynctask-executor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from artem-zinnatullin/android-asynctask-executor

0.0 2.0 0.0 172 KB

DEPRECATED You want to execute your AsyncTask concurrently on any version of Android OS? You need AsyncTaskExecutor!

Java 100.00%

android-asynctask-executor's Introduction

#Android-AsyncTask-Executor

#VERY OUTDATED, PLEASE DON'T EVER USE THIS Take a look at PriorityJobQueue, RxJava and other libraries for concurrent data processing

##Why use it? Starting with Android Api >= HONEYCOMB AsyncTasks are executed on serial, which means that you could not run 2 or more AsyncTasks concurrently without calling task.executeOnExecutor(...), it is not so easy as you would like to think.

AsyncTask-Executor takes all work for running AsyncTask concurrently on any Android OS version, it is better that using:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
    task.execute();
}

Because AsyncTask.THREAD_POOL_EXECUTOR available only on api >= 11; I`m using my own threadPoolExecutor

###With AsyncTaskExecutor you just need to write:

AsyncTaskExecutor.executeConcurrently(task, params, ...);

And that is all. No errors on Android 2.x, 3.x and 4.x


#####Please, look in UsageExampleActivity.java to see usage example of AsyncTaskExecutor


###How to import AsyncTask-Executor to your Android Project?

  • Just copy AsyncTaskExecutor.java to your Android project! (Simplest way)

  • Or use AsyncTaskExecutor as Android Library Project (Good way, if you want to see javadoc)

  • Or just use .jar file, look at Jar folder to get it (Easy way)


####Do not forget! AsyncTaskExecutor.executeConcurrently() returns executing AsyncTask object and you can do what you want with it. For example, you could cancel running task or anything else you could do with AsyncTask object.

android-asynctask-executor's People

Contributors

artem-zinnatullin avatar

Watchers

James Cloos avatar dev.with avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.