Note that there are some explanatory texts on larger screens.

plurals
  1. POIs using AsyncTask still recommended for loading listView items in the background?
    primarykey
    data
    text
    <h2>Background</h2> <p>I've heard that there are some new solutions for loading data in the background which are more recommended than AsyncTask (like <a href="http://developer.android.com/reference/android/content/Loader.html" rel="nofollow noreferrer">loaders</a>).</p> <h2>The problem</h2> <p>AsyncTasks are great and easy to use. However, it has some limitations:</p> <ol> <li><p>The class itself has to be modified since it's limited by the number of pending tasks (about 256 or so). Of course, in a listView's adapter, I always cancel a task if it's not needed(for example when I need to update a view that was used for a different item).</p></li> <li><p>I also have to cancel them all (or handle in a different way) when the activity/fragment is being re-created.</p></li> <li><p>Because of 1&amp;2, I need to manage them and have a reference to all of them</p></li> <li><p>AsyncTask uses a queue of tasks, and sometimes I need to use a stack instead, so I had to create my own class of AsyncTask that uses a stack instead.</p></li> </ol> <h2>The question</h2> <p>Are there alternatives for AsyncTask?</p> <p>I know this was asked in some posts before (like <a href="https://stackoverflow.com/questions/10422697/android-loaders-the-way-to-go">here</a>), but I was thinking if there is a new general way to load data in the background which replaces the asyncTask.</p> <p>About Loaders, I think the idea is that they are used for databases and contentProviders, but can they also be used for loading (for example) data from the Internet (like images files) ?</p> <p>There is also a nice sample made by google (<a href="http://developer.android.com/training/displaying-bitmaps/index.html" rel="nofollow noreferrer">here</a>, called "bitmapFun"), which according to what I see uses AsyncTask (and even extend it, maybe because of the same reasons I've mentionsed) . But maybe I'm missing there something too?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload