Questions tagged [asynctaskloader]

AsyncTaskLoader is an Android Loader that uses an AsyncTask to do the loading of data in a background thread.

The AsyncTaskLoader, like other types of Android Loaders, is a class that can be used to avoid having to load data on the main UI thread(loading which may block the UI thread and the app itself). The AsyncTaskLoader was introduced in the Android SDK starting with API level 11(Honeycomb) but is available in older versions through the Android compatibility package. More information about the AsyncTaskLoader along with examples of using one can be found in the documentation for the class.

200 questions
30
votes
7 answers

AsyncTaskLoader doesn't run

I want to implement an AsyncTaskLoader in my project using the Compatibility Package, so I followed the Loader manual in Android Docs. The problem is that the Loader does nothing, it seems loadInBackground() is never called Any idea of what's wrong…
Aitor Gómez
  • 7,105
  • 3
  • 17
  • 27
29
votes
5 answers

Data out of sync between a custom CursorLoader and a CursorAdapter backing a ListView

Background: I have a custom CursorLoader that works directly with SQLite Database instead of using a ContentProvider. This loader works with a ListFragment backed by a CursorAdapter. So far so good. To simplify things, lets assume there is a Delete…
24
votes
4 answers

AsyncTaskLoader onLoadFinished with a pending task and config change

I'm trying to use an AsyncTaskLoader to load data in the background to populate a detail view in response to a list item being chosen. I've gotten it mostly working but I'm still having one issue. If I choose a second item in the list and then…
23
votes
6 answers

What is the appropriate replacement of deprecated getSupportLoaderManager()?

I came to know that getSupportLoaderManager is deprecated. But I want to call: getSupportLoaderManager().initLoader(0, null, mRecipeLoaderManager); What should be an alternative to that call? Or can I still use getSupportLoaderManager without…
fabi
  • 404
  • 1
  • 4
  • 11
18
votes
6 answers

Real difference between AsyncTask and Thread

I have been reading Android documentation (AsyncTask, Thread) and vogella tutorial about this matter, but I have doubts yet. For example, I want to send a message from an Android app to a server. And I would like this process to be responsive. What…
16
votes
6 answers

Update progressbar from AsyncTaskLoader?

When using a AsyncTaskLoader how would you update a progressbar showing the status as it is being updated? Normally you wait for the callback to remove when done, but how to do running updates? Would you let the main thread (ui) poll the data as it…
Warpzit
  • 27,293
  • 18
  • 98
  • 146
14
votes
2 answers

How to handle errors in custom AsyncTaskLoader?

I am extending AsyncTaskLoader which I use later in a Fragment through LoaderManager. Is there suggested way to handle errors which occur during async task? I would like to popup message asking user to cancel or retry when internet connection error…
Malachiasz
  • 6,621
  • 2
  • 31
  • 46
13
votes
2 answers

Testing AsyncTaskLoaders with Robolectric

Has anyone had any luck writing unit tests for AsyncTaskLoaders in Robolectric? I tried a modified version of this example for AsyncTask, but it doesn't exhibit the same behavior. In particular onLoadFinished is never called. Are there any workable…
Christopher Perry
  • 36,832
  • 42
  • 136
  • 182
9
votes
4 answers

What does AsyncTaskLoader.deliverResult() actually do?

I am trying to understand some finer points of AsyncTaskLoaders. This may be obvious, to others but I can't find an unambiguous example or definition that demonstrates and exmplains what happens when you override the deliverResult() method. What…
angryITguy
  • 8,747
  • 8
  • 51
  • 79
9
votes
1 answer

Custom AsyncTaskLoader, loadinBackground not called after 5 attempts

I have a SherlockListFragment that implements a custom AsyncTaskLoader. In the overridden onStartLoading(), I have: @Override protected void onStartLoading() { if (mData != null) { deliverResult(mData); } else{ forceLoad(); } } The…
Magnus Johansson
  • 26,737
  • 17
  • 96
  • 157
8
votes
1 answer

Using LoaderCallbacks without Fragment

I am doing some hands-on reading on AsyncTaskLoader so I can use the technique to load the contact list. The only time the code works is when I implement the callbacks from a class that extends Fragment as in MyLoader extends Fragment implements…
learner
  • 11,452
  • 24
  • 87
  • 160
7
votes
1 answer

Android - Thread pool strategy and can Loader be used to implement it?

First the problem: I'm working on the application that uses multiple FragmentLists within a customized FragmentStatePagerAdapter. There could be, potentially substantial number of such fragments say between 20 and 40. Each fragment is a list in…
Bostone
  • 34,822
  • 38
  • 158
  • 216
7
votes
0 answers

How does cancelling an AsyncTaskLoader work?

I've noticed the following functions for AsyncTaskLoader,Loader and LoaderManager : cancelLoadInBackground cancelLoad destroyLoader, abandon, reset Thing is, I don't get how they work: What's the difference between them? Does any of them call…
android developer
  • 106,412
  • 122
  • 641
  • 1,128
6
votes
1 answer

Incompatible types in method onCreateLoader working with AsyncTaskLoader and Fragment

I considered some examples of working with AsyncTaskLoader and Fragment (https://gist.github.com/codeswimmer/884591) and I tried to do the same. But now I can't fix incompatible types error - in method onCreateLoader. I have no idea why it happens,…
Daryn K.
  • 571
  • 1
  • 8
  • 20
6
votes
1 answer

How to pass params to Android AsnycTaskLoader

I'm trying to pass params into a AsyncTaskLoader. How do I do that? Currently, I'm putting what I need to pass in in a separate static class. Anyway around this? public class NewsAsyncTaskLoader extends AsyncTaskLoader> { private…
Bryan
  • 2,982
  • 2
  • 21
  • 29
1
2 3
13 14