Questions tagged [android-loader]

Loader is an abstract class that performs asynchronous loading of data.

A class that performs asynchronous loading of data. While Loaders are active they should monitor the source of their data and deliver new results when the contents change.

Note on threading: Clients of loaders should as a rule perform any calls on to a Loader from the main thread of their process (that is, the thread the Activity callbacks and other things occur on). Subclasses of Loader (such as AsyncTaskLoader) will often perform their work in a separate thread, but when delivering their results this too should be done on the main thread.

Most implementations should not derive directly from this class, but instead inherit from AsyncTaskLoader.

Useful links

197 questions
116
votes
3 answers

LoaderManager with multiple loaders: how to get the right cursorloader

To me it's not clear how to get the right cursor if you have multiple Loaders. Lets say you define two different Loader with: getLoaderManager().initLoader(0,null,this); getLoaderManager().initLoader(1,null,this); then in onCreateLoader() you do…
Kay Gladen
  • 1,730
  • 2
  • 14
  • 14
36
votes
3 answers

Loaders in Android Honeycomb

I'm trying to figure out how to use Loaders in Android 3.0 but can't seem to get it to work. The docs only describe using CursorLoader but I'm using AsyncTaskLoader. From the docs it seems that you should only need to implement…
31
votes
2 answers

When to use Android Loaders

Loaders monitor data source and deliver new results After a configuration change : no need to re-query the data I read the android guide about Loaders. I read Alex Lockwood 4 parts tutorial . Tested his sample app too. Tried to read the Google App…
test2558
  • 335
  • 4
  • 8
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…
22
votes
4 answers

Android Volley + Loader pattern?

I kinda liked Volley framework, but I still have some doubts about it. For example, how does Volley line up with Loader pattern? Since it's requests are handled in an async manner, calling it on background doesn't make much sense. On the other hand,…
husrevo
  • 331
  • 2
  • 6
16
votes
1 answer

What is the scope of LoaderManager?

When creating an Android application using Loaders, should every activity and fragment have its own LoaderManager? Or should there only be one LoaderManager that the application owns? And lastly, are the "unique IDs" that are used to identify…
Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
15
votes
1 answer

Will LoaderManager.restartLoader() always result in a call to onCreateLoader()?

LoaderManager has this method restartLoader(): public abstract Loader restartLoader (int id, Bundle args, LoaderCallbacks callback) Starts a new or restarts an existing Loader in this manager, registers the callbacks to it, and (if the…
Maarten
  • 6,894
  • 7
  • 55
  • 90
15
votes
2 answers

Should Loaders be used to access web services?

For what I understand, the Loader framework is geared towards accessing data stored locally in a ContentProvider / SQLite database. We have the CursorLoader class that handles this use case quite well. But I wonder if it's practical to use the…
Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101
14
votes
2 answers

Why is onLoadFinished called again after fragment resumed?

I have a peculiar issue with Loaders. Currently I am unsure if this is a bug in my code or I misunderstand loaders. The app The issue arises with conversations (imagine something similar to Whatsapp). The loaders I use are implemented based on the…
Patrick
  • 4,720
  • 4
  • 41
  • 71
14
votes
2 answers

Android Loader not triggering callbacks on screen rotate

I am using an AsyncTaskLoader. I have an activity which has implemented LoaderCallbacks (Support library). I have breakpoint debugged and put in logs, the loader delivers the result, however the second time the callback onLoadFinished is not…
serenskye
  • 3,467
  • 5
  • 35
  • 51
13
votes
2 answers

Can Honeycomb Loaders solve problems with AsyncTask + UI update?

Doing something in background and then updating UI is very hard to implement correctly in Android. It's simply badly designed. Typical example is an AsyncTask that fetches something from the web and displays the result. There are 2 problems with…
fhucho
  • 34,062
  • 40
  • 136
  • 186
13
votes
3 answers

Loader delivers result to wrong fragment

I have an activity with swiping tabs using ActionBar tabs, based on the android developer example. Each tab displays a Fragment, and each Fragment (actually, a SherlockFragment) loads a different kind of remote api request via a custom…
12
votes
2 answers

What can cause StaleDataException other than prematurely calling cursor.close()?

I'm currently heavily modifying/rewriting an Android app and I have seen a very occasional crash along the following lines: a CursorAdapter method is called, it calls AbstractWindowedCursor#checkPosition(), and: 02-20 15:03:18.180…
11
votes
6 answers

What is the advantage of loaders over Asynctask in Android?

Are there any advantages of Loaders over Async task? Also, how to make loaders compatible for phones with Android froyo. Edit: The primary problem here is that I'm not using the native DB(SqlLite). Using the DB on development server. Obviously, I…
Hick
  • 35,524
  • 46
  • 151
  • 243
1
2 3
13 14