Questions tagged [android-loadermanager]

An abstract class associated with an Activity or Fragment for managing one or more Loader instances. This helps an application manage longer-running operations in conjunction with the Activity or Fragment lifecycle; the most common use of this is with a CursorLoader, however applications are free to write their own loaders for loading other types of data.

Interface associated with an Activity or Fragment for managing one or more Loader instances associated with it. This helps an application manage longer-running operations in conjunction with the Activity or Fragment lifecycle; the most common use of this is with a CursorLoader, however applications are free to write their own loaders for loading other types of data.

While the LoaderManager API was introduced in HONEYCOMB, a version of the API at is also available for use on older platforms through FragmentActivity.

There is only one LoaderManager per activity or fragment. But a LoaderManager can have multiple loaders.

Useful links

394 questions
15
votes
3 answers

Using CursorLoader to query SQLite DB and populate AutoCompleteTextView

I have a SQLite database I would like to query. I want to target Android 2.2 through ICS. I came across this article on how to do this, but it uses deprecated code (does not query asynchronously, but on the UI thread). I've since read that I can use…
mraviator
  • 4,034
  • 9
  • 38
  • 51
15
votes
1 answer

How to transition from managedQuery to LoaderManager/CursorLoader?

I'm developing an Android application that is targeting API level 8 (2.2, Froyo). I'm using a ContentProvider and that's simple enough, and I'm using SimpleCursorAdapter to fill out my list view, but I noticed in the documentation for…
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
3 answers

Why does my OnLocationChanged() never get called?

What I am trying to do: I am trying to develop an app that only requires the user's location at the start of one activity. So only when the user is within the activity, the location gets updated either by network or GPS. Accordingly, the user may…
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
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
1 answer

Android: CursorLoader crash on non-topmost Fragment

I have a few ListFragments that use a CursorLoader to retrieve their content. As the user drills down through the content, one Fragment replaces another (the Activity remains the same). But if the content changes on a non-topmost Fragment, the app…
14
votes
3 answers

ExpandableListFragment with LoaderManager for Compatibility Package

I want to make my ExpandableListActivity compatible with Honeycomb. I am wondering why there is no ExpandableListFragment for the Compatibility Package. Is there a way to make ExpandableListView work with the normal Fragment class? How do I load the…
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

What does LoaderManager do?

I am trying to understand what does LoaderManager do. Can anyone share an example with it? Must I use them when I create a cursor? If not how should I use? A simple example is very appreciated.
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…
13
votes
1 answer

What to set CursorAdapter(Context context, Cursor c, int flags) to in order to make it work with CursorLoader?

The google docs point out not to use the CursorAdapters first constructor, CursorAdapter(Context context, Cursor c) There are only two other options, CursorAdapter(Context context, Cursor c, boolean autoRequery) which says Constructor that…
12
votes
3 answers

Pattern for multiple Loaders with LoaderManager?

I'm using Fragments and LoaderManager. I have to launch an unknown number of tasks, and they might be run in parallel (otherwise I'd just reuse one and only one loader). For example, I have a listview, and each row might have a button to save the…
user291701
  • 38,411
  • 72
  • 187
  • 285
12
votes
1 answer

Preferred method of loading dependent queries with LoaderManager

What is the preferred method of loading dependant queries with the LoaderManager API in Android? As of now the best I could come up with is something along the lines of: @Override public void onCreate( Bundle savedInstanceState ) { …
Andreas Hagen
  • 2,335
  • 2
  • 19
  • 34
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…
1 2
3
26 27