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

which one is better: Loader or Headless Fragments

Since, there has always been some issues with AsyncTask. So, now, i am thinking about to move to either Loader or Headless Fragments. My app is a social media app, where people comment, post, likes and do much more things.. Each Activity fetches…
5
votes
1 answer

Proper notification of AsyncTaskLoader about data changes from background thread

I want to implement AsyncTaskLoader for my custom data source: public class DataSource { public interface DataSourceObserver { void onDataChanged(); } ... } DataSource will keep list of registered observers and will notify them…
Sokolof
  • 2,271
  • 2
  • 19
  • 30
5
votes
2 answers

onResume() not called on ViewPager fragment when using custom Loader

Short version: I have a fragment that maintains a ViewPager for displaying two other fragments, let's call them FragmentOne and FragmentTwo. When starting the app FragmentOne is visible and FragmentTwo is off-screen, becoming visible only as one…
5
votes
1 answer

Multiple Loaders with LoaderManager, not getting right Loader

I have two loaders, one to populate bind returned data to 2 TextViews and another to populate a ListView. How do I make sure the correct loader loads for each situation? I am getting an error in the where first loader (WR_VIEW case) doesn't seem to…
jocey
  • 252
  • 4
  • 14
5
votes
3 answers

Unittesting AsyncTaskLoader with getLoaderResultSynchronously

I am trying to create unit tests for a REST client that does some API calls. The client works fine in the live application, but I can't get it to run in the test case. Apparantly, LoaderTestCase.getLoaderResultSynchronously() could be used here (at…
M. Meiboom
  • 164
  • 10
4
votes
2 answers

android getContentResolver().notifyChange() does not restart my loader

codes: First my Uris public static final String PACKAGE = "my.url.contentprovider"; public static final String TABLE_NAME = "NetworkTransaction"; public static final String AUTHORITY = PACKAGE + ".NetTransContentProvider"; public static final…
4
votes
0 answers

AsyncLoaderTask stops loading randomly (loadInBackground() stops getting called)

I have a class that extends AsyncTaskLoader and which frequently receives updates. Now when the app initially starts everything works fine, the UI (a SherlockListFragment (so I am using the compatability library) that implements…
Kent Hawkings
  • 2,793
  • 2
  • 25
  • 30
4
votes
3 answers

How to interrupt AsyncTaskLoader's background thread?

Is there some way to interrupt AsyncTaskLoader's loadInBackground() thread when I call cancelLoad()? I believe that AsyncTask.cancel() does this but the task variables are private and cannot be accessed.
4
votes
2 answers

IllegalStateException "attempt to re-open an already-closed object" in SimpleCursorAdapter from ContentProvider

I have a series of ListView objects in Fragments that are being populated by a CursorAdapter which gets a Cursor from the LoaderManager for the activity. As I understand it, all database and Cursor close actions are completely handled by the…
4
votes
1 answer

Android Loaders lifecycle, or: will onStopLoading() always called before onReset()?

Could there be a case in which onReset() is called without calling onStopLoading() directly before it? More generally, I'm trying to figure out the Loader's life-cycle, a-la the Activity lifecycle chart, and which onSomething()s run inside which…
Daniel
  • 2,728
  • 3
  • 21
  • 33
4
votes
2 answers

Start Activity in onLoadFinished method

I have DialogFragment and a Loader. Dialog prompts user to logout from Application. When user chooses to logout I fire Loader which clears the preferences and database and then I finish current Activity. After Loader is finished I would like to…
4
votes
3 answers

Android TabsAdapter with ActionbarSherlock

I am using ActionbarSherlock with a SherlockListFragment that implements LoaderManager.LoaderCallbacks. In my ApplicationActivity onCreate method I am using setContentView(R.layout.application); to set the layout -- works great. I am initializing…
3
votes
0 answers

Appwidget does not update correctly

I developed an appwidget, and it's a collection widget and use a Loader to retrieve the data from a database, and when a user clicks on the list item, that items details will be saved into a bundle in an intent, and the main activity will be…
3
votes
2 answers

How to stop loader correctly?

I use class which extended Loader. How can I stop my loader after I get result? When I rotate phone I get result again: @Override public void onLoadFinished(Loader loader, Data data) { makeWorkWithData(); //... finish this…
Artem
  • 4,569
  • 12
  • 44
  • 86
3
votes
4 answers

What is the best way for fetching data and for passing to another Activity?

Most the app so far I had created, I fetch the data from Network and store it in a singleton class to share data between Activities, when I'm done with those data, I usually clear those setting it to NULL, its work perfectly well My Question is…
sreekumar
  • 2,439
  • 1
  • 21
  • 27
1 2
3
13 14