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
3
votes
1 answer

When an Activity instance is destroyed during a configuration change, are the Loaders associated with it also destroyed?

From this developer guide on Loaders, They automatically reconnect to the last loader's cursor when being recreated after a configuration change. Thus, they don't need to re-query their data. I assume that by "last loader", they mean that the…
Solace
  • 8,612
  • 22
  • 95
  • 183
3
votes
1 answer

LoaderCallbacks.onLoadFinished() is not called after load finishes

I created a loader that descends from AsyncTaskLoader. It works 99% of the time, but there's an edge case where LoaderCallbacks.onLoadFinished() is not called after AsyncTaskLoader.loadInBackground() returns successfully. I don't know what's…
Barry Fruitman
  • 12,316
  • 13
  • 72
  • 135
3
votes
1 answer

getLoaderManager().initLoader() doesn't accept 'this' as argument though the class (ListFragment) without support libraries

I have seen the previuos question import android.app.ListFragment; import android.app.LoaderManager.LoaderCallbacks; import android.database.Cursor; import android.os.Bundle; import android.support.v4.app.LoaderManager; import…
3
votes
1 answer

Android Custom Loader, LoaderManagerImpl.LoaderInfo.callOnLoadFinished only called once

I am trying to implement my own custom Android Loader to be able to use the LoaderManager benefits in my application (decoupling of loading data with lifecycle of my Activities and Fragments). I have first considered subclassing from AsyncLoader,…
Boeboe
  • 2,070
  • 1
  • 17
  • 21
3
votes
2 answers

AsyncTaskLoader doesn't call onLoadFinished unless I return a new object in loadInBackground

I have a AsyncTaskLoader> with a member variable List mAddresses. In loadInBackground, if I create a new object, fill it, and return it; onLoadFinished is called as expected, so I can update the adapter which in turn updates the…
David Doria
  • 9,873
  • 17
  • 85
  • 147
3
votes
1 answer

onLoadFinished not called on offscreen fragment until going back

I'm trying to implement List->Detail scheme with details pagination. I've single Activity for ListView and different Activity with ViewPager. In FragmentStatePagerAdapter.getItem i instatniate new fragment for page and pass item id via setArguments…
3
votes
0 answers

Loader framework and activity lifecycle

I really like loaders and their benefits. But i meet a problem which i don't know how to solve. In my activity i use AsyncTaskLoader to load some data from database and provide cursor to the onLoadFinished(Loader loader, Cursor cursor)…
Johnny Doe
  • 3,280
  • 4
  • 29
  • 45
3
votes
1 answer

Loader is not retained after starting new activity, changing orientation in new activity and pressing back button

I been running into an issue with loaders lately. I created a small project that reproduces the issue https://github.com/solcott/loaders-orientation-change I have a simple Activity that adds a fragment public class MainActivity extends Activity { …
solcott
  • 58
  • 4
3
votes
1 answer

CursorLoader connecting to wrong ContentProvider

The Problem CursorLoader instantiation seems to be using URI of previous CursorLoader, rather than the URI passed in as an argument. CursorLoader cursor = new CursorLoader(this, FLASHCARD_CONTENT_URI, FLASHCARD_FROM, null, null, null); is giving…
Michael Pell
  • 1,416
  • 1
  • 14
  • 17
3
votes
0 answers

Multiple Fragments in TabsPager with Loaders, swiping works, clicking doesn't

I am using an ActionBarSherlock example to build on. I have 3 fragments (each extends SherlockListFragment and implement LoaderManager.LoaderCallbacks<>), 1 in each tab. They all use loaders. Tabs 2 and 3 use the same loader class (I don't think…
3
votes
1 answer

Android: Unable to load simple html data having javascript file in WebView?

WebView web_view = (WebView) findViewById(R.id.webView1); web_view.getSettings().setJavaScriptEnabled(true); web_view.getSettings().setPluginsEnabled(true); web_view.getSettings().setAllowFileAccess(true); String…
Teekam
  • 939
  • 4
  • 14
  • 26
3
votes
0 answers

Custom AsyncTaskLoader class doesn't honor calls to forceLoad

This is a bit of a weird problem. I'm using a class that extends AsyncTaskLoader (real deal targeting API level 11, not the compatibility one) to receive intents sent by another app component and respond by downloading some data from a local…
2
votes
1 answer

What is the purpose of onCanceled() in Android Loader

I have implemented a Loader where in onStopLoader(), I have called cancelLoad() method. However despite the above call, onCanceled() is not getting called. What is the purpose of this callback? On pressing the home button in my Activity, I can see…
Sumit Trehan
  • 3,985
  • 3
  • 27
  • 42
2
votes
1 answer

What's defference between AsyncTaskLoader and Loader?

Cannot understand when I need to use Loader and when AsyncTaskLoader? I read docs by these class but I understood it badly. As I understood Loader allows to do a background work so it must be launched in non-GUI thread, it isn't? Why does…
Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
2
votes
1 answer

Why can't Loaders be non-static inner classes?

When I try to use a non-static inner Loader class, I get the following runtime error: Object returned from onCreateLoader must not be a non-static inner member class What's the point of this restriction?
Barry Fruitman
  • 12,316
  • 13
  • 72
  • 135