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
10
votes
5 answers

Android - onLoadFinished not called

I am facing an issue with Loader. I have an Activity, which displays list of records retrieved from local DB. When the activity starts, records are automatically loaded via LoaderManager.initLoader() method. There is also possibility to manually…
petlack
  • 216
  • 1
  • 2
  • 9
9
votes
3 answers

How can I implement a simple AsyncTaskLoader?

In one of my recent SO questions, someone suggested that I use Loader for my solution. So here I am trying to understand how to implement a simple AsyncTaskLoader Here's what I've come up with: public class Scraper extends…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
7
votes
2 answers

Way to update UI after database change has occured

I'm developing an app based on Google IO presentation architecture using the first approach. Basically I have a Service, ContentProvider backed by SQLite DB and I also use Loaders. I need a way to update UI when changes to my database occur. For…
midnight
  • 3,420
  • 3
  • 36
  • 58
7
votes
1 answer

Loader: onLoadFinished called only once

I have one loader being used in an activity. I'm able to start the loader and it onLoadFinished is called. When I update data and call onContentChanged in the loader i see that loadInBackground and deliverResult are both called. This is where the…
7
votes
2 answers

Android Fragment - Using activity's loadermanager instead of Fragment's. Is it Ok?

Given a fragment which loads (a lot of) data from the database using a loader. Problem : I have a pager adapter which destroys the fragment when the user moves away from the tab holding it and recreates it when user gets back to that tab. Because of…
500865
  • 6,920
  • 7
  • 44
  • 87
6
votes
0 answers

When an activity is destroyed due to a configuration change, are its Loaders destroyed as well?

From the 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. From this blog post on Loaders, when an Activity is…
6
votes
2 answers

Add 1000's Markers to android Googlemap

I am developing a GoogleMap based android application. I need to display 1000's of Markers on the map. Currently I retrieve the Latitude and Longitude for each marker from an SQLite database loader and add the markers in the public void…
Hector
  • 4,016
  • 21
  • 112
  • 211
6
votes
2 answers

Tell Android AsyncTaskLoader to retrieve more data

Let me start off by saying this is NOT a question about scrolling ListViews. I do not want to know how to tell when a user scrolls to the bottom of a list, so please do not give me answers for that question, or mark this as a duplicate. I am using a…
drewhannay
  • 1,030
  • 6
  • 12
6
votes
3 answers

Difference between restartLoader and onContentChanged

Currently, I have a loader @Override public Loader> onCreateLoader(int arg0, Bundle bundle) { return new HomeMenuRowInfosLoader(this.getSherlockActivity()); } Sometimes, I need to ask the loader to reload again, due to…
Cheok Yan Cheng
  • 47,586
  • 132
  • 466
  • 875
6
votes
3 answers

Show Progress Indicator before fill listview using CursorLoader

What better way to show a progress indicator while my listview is not filled with data of database? I found some examples of how to do this, using assynctask, but in my case, I am using Loader /CursorLoader. public class TestActivity extends…
elirigobeli
  • 1,391
  • 2
  • 15
  • 22
6
votes
3 answers

Is using AsyncTask still recommended for loading listView items in the background?

Background I've heard that there are some new solutions for loading data in the background which are more recommended than AsyncTask (like loaders). The problem AsyncTasks are great and easy to use. However, it has some limitations: The class…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
5
votes
1 answer

Loader load only selected row + next row

In activity A I am loading a list with all the values from my table and have set a setOnItemClickListener to start activity B and send an uri with the selected item's id[1] via send data [1] Uri currentTestUri =…
Alin
  • 1,218
  • 5
  • 21
  • 47
5
votes
1 answer

Android loading progress bar with custom image and progress indicator

Apologies if this seem trivial. I have been working on my first android app and would like advise on best way to implement a loading/splash screen attached. My designer came up with is loading/splash screen and I am not sure how to implement…
Babajide Prince
  • 552
  • 1
  • 10
  • 25
5
votes
1 answer

Can loaders be used without content provider or combination is must?

Can loaders be used without content provider or combination is must? Is it best practice to use content provider only when it is intended to use by other applications or for only local use also content provider is recommended? If data updated in…
Darshan Kapasi
  • 187
  • 1
  • 2
  • 14
5
votes
1 answer

Explain AsyncTaskLoader

I don't understand what all the functions in AsyncTaskLoader do, such as onCancelLoad() and onForceLoad(). All the functions and the order in which they're called are not documented properly. Say I want to download a file in the background and…
1
2
3
13 14