Questions tagged [asynctaskloader]

AsyncTaskLoader is an Android Loader that uses an AsyncTask to do the loading of data in a background thread.

The AsyncTaskLoader, like other types of Android Loaders, is a class that can be used to avoid having to load data on the main UI thread(loading which may block the UI thread and the app itself). The AsyncTaskLoader was introduced in the Android SDK starting with API level 11(Honeycomb) but is available in older versions through the Android compatibility package. More information about the AsyncTaskLoader along with examples of using one can be found in the documentation for the class.

199 questions
6
votes
1 answer

Using LoaderCallbacks without Fragment

I am doing some hands-on reading on AsyncTaskLoader so I can use the technique to load the contact list. The only time the code works is when I implement the callbacks from a class that extends Fragment as in MyLoader extends Fragment implements…
learner
  • 11,490
  • 26
  • 97
  • 169
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…
5
votes
1 answer

Android. Yor own progress-bar?

4th hour of searching and No results all the same. A fact that we should not. Tell me how to implement the following: There AsyncTask that performs certain actions There are 25 pictures of the following form: Image There Sheet Animation xml: …
5
votes
5 answers

Update UI from an AsyncTaskLoader

I've converted my AsyncTask to an AsyncTaskLoader (mostly to deal with configuration changes). I have a TextView I am using as a progress status and was using onProgressUpdate in the AsyncTask to update it. It doesn't look like AsyncTaskLoader has…
Kris B
  • 3,436
  • 9
  • 64
  • 106
4
votes
2 answers

AsyncTask is deprecated? What method used instead of onPreExecute and onPostExecute?

In my old project, I used AsyncTask, but its deprecated so what method i used instead of this? If we used thread, in AsyncTask having onbackground, onPreExecute and onPostExecute Override methods where this sections called in thread. Is there any…
Ana
  • 174
  • 1
  • 2
  • 10
4
votes
1 answer

Android anonymous class Loaders leak safe?

In Android development, I've learnt that AsyncTask defined as a non-static nested class is not ideal because it may cause memory leaks when the Activity that started the task, dies before the task has finished processing. So the solution to use…
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
1 answer

Custom AsyncTaskLoader with cache

There are several tutorials on how to implement custom AsyncTaskLoaders but none I found discusses how to handle data caching - in all of them the data are just loaded and delivered. Can you give me some hints how to implement custom AsyncTaskLoader…
Blackhex
  • 1,694
  • 3
  • 21
  • 45
4
votes
1 answer

How to tell if AsyncTaskLoader is running

I am starting a AsyncTaskLoader using this: getLoaderManager().initLoader(0, null, this); I thought I could use this to tell if it's running: Boolean isRunning = (getLoaderManager().getLoader(0) != null &&…
Kris B
  • 3,436
  • 9
  • 64
  • 106
3
votes
3 answers

How to Use MVVM With asyncTask or any other thing?

I want to use AsyncTaskLoader but it was deprecated so came to know that in place of AsyncTaskLoader I can use ViewModel and live data or mutable data but I don't know how to use them with the async task.
AiverReaver
  • 164
  • 2
  • 10
3
votes
2 answers

Android: HttpUrlConnection object returns error 301 after connection

I'm trying to connect to a web API using a URL. However, I get a 301 error from the server (Moved Permanently), although the provided URL works very well with no errors when I try it in my browser. Here is the code that builds the URL: public…
Dania
  • 1,648
  • 4
  • 31
  • 57
3
votes
0 answers

How to change fragments depending on a result of async request

I want to manage fragments on my screen depending on a result of async request to local database. E.g: 1. Go to database 2. Get results 3. Once results are delivered, choose a fragment that should be shown to a user. (Something like in the code…
3
votes
1 answer

What is the lifecycle of Loaders?

Background I'm working on making an app better by supporting its landscape mode. One thing that I use a lot is Loaders, or more specifically AsyncTaskLoaders . Using Loaders allow you to keep doing a background task even if the activity is being…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
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

LoaderManager: how to get the right loader from with multiple different loaders?

Now I want to create several AsyncTaskLoaders with different types. One could be: public Loader> onCreateLoader(int id, final Bundle args) { ... } The other one could be: public Loader onCreateLoader(int id, final…
Grace Huang
  • 5,355
  • 5
  • 30
  • 52
1
2
3
13 14