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

AsynLoaderTask and ViewPager

I have a ViewPager with a FragmentStatePagerAdapter. In the onViewCreated method of the ViewPager fragments I call the initLoader method of the LoadManager to start an AsyncTaskLoader like this public void onViewCreated(final View view, Bundle…
mollymay
  • 512
  • 4
  • 13
3
votes
2 answers

Populating a ListView using AsyncTaskLoader

I'm having problems using AsyncTaskLoader. This is my first attempt populating a ListView from a SQLite database using a loader. Everything seems ok, when I rotate the screen the data is cached and no query is done again. But when I press the home…
Marcos
  • 4,643
  • 7
  • 33
  • 60
3
votes
0 answers

RejectedExecutionException 128 Active Threads AsyncTaskLoader

I've searched around for solutions to RejectedExecutionException using AsyncTaskLoader but none have worked. Most of them are for AsyncTask like https://github.com/commonsguy/cwac-task/blob/master/src/com/commonsware/cwac/task/AsyncTaskEx.java but…
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…
3
votes
1 answer

Proper way of Fetching request from web service on android

I was just wondering which is the best way to fetch data from a web service using HTTP request. Using AsyncTask or AsyncTaskLoader I'm using AsyncTaskLoader using LoaderManager on the activity but I encounter problems when there are configuration…
2
votes
1 answer

How should a SQLiteDatabase connection be handled inside an AsyncTaskLoader?

I wondering where and when I should open/close my SQLiteDatabase connection in my AsyncTaskLoader. I don't feel like i fully understand the lifecycle of a Loader, so I'm afraid that I might run into some memory leaks/NullPointerExceptions if I…
soren.qvist
  • 7,376
  • 14
  • 62
  • 91
2
votes
1 answer

This Loader class should be static or leaks might occur | Inner class memory leak | AsyncTaskLoader memory leak -

I am receiving the following warning around AsyncTaskLoader in android studio: "This Loader class should be static or leaks might occur (anonymous android.support.v4.content.AsyncTaskLoader) less... (Ctrl+F1) A static field will leak contexts. …
2
votes
2 answers

Is "leaking" context inside AsyncTaskLoader that bad?

I have an AsyncTaskLoader that does some background task. While doing this task, it needs to access some views. (No I can't just get the values of the views beforehand - they are custom views, with some magic stuff attached to it - please just…
AlanSTACK
  • 5,525
  • 3
  • 40
  • 99
2
votes
1 answer

Does OkHttp's enqueue method implement AsyncTaskLoader?

I am pretty new to android programming. I've written a code to perform API query using the OkHttp Library. My question is, once the OkHttp's enqueue process has started, and the user immediately rotates the phone, thereby destroying and restarting…
Chao Li
  • 175
  • 10
2
votes
1 answer

Can I run many Loaders at the same time in the same activity?

I have a doubt about the use of Loader. In my case, I call my own class that extends AsyncTaskLoader and return a List of MyObject. public class MyActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks> { …
MDP
  • 4,177
  • 21
  • 63
  • 119
2
votes
2 answers

Should I excute Insert, Delete, Update on my own SQLite DB inside AsyncTaskLoader

I read many posts telling long operations (like reading DB) should not be excuted on the main Thread. So far I used CursorLoader (for "reading" ContentResolver) andAsynkTaskLoader(for "reading" my own SQLite DB). I know to perform Insert, Delete and…
MDP
  • 4,177
  • 21
  • 63
  • 119
2
votes
1 answer

Run asynchronous method in loadInBackground of AsyncTaskLoader

I would like to run asynchronous server call using AsyncTaskLoader. Method loadInBackground() should return the result synchronously. I am returning null and I call deliverResult() in callback which is executed on manually created HandlerThread.…
matusalem
  • 2,461
  • 2
  • 26
  • 35
2
votes
0 answers

getLoaderManager().initLoader(); always returns a new loader when using support.v4.fragment

I'm using android.support.v4.content.AsyncTaskLoader to load data into a support.v4.fragmentbut when the configuration changes i.e : rotate the screen getLoaderManager().initLoader(); always returns a new loader thus loadInBackground() is called…
2
votes
1 answer

Asynctaskloader restart loading when the activity restart

Hi I'm implementing a custom asynctaskloader to load data in the background. The problem is when the user goes back to the activity after he minimizes the app(or pick photo from gallary), all the asynctaskloaders associated with the activity and…
danial
  • 75
  • 9
2
votes
2 answers

How do I avoid network on main thread exception if I already use AsyncTask?

It seems to me I m not really calling URL,network operations right from MainActivity. I do call url.connect() in another class ProcessData I do use doInBackground() I do extend ProcessData class with AsyncTask but the exception still…
ERJAN
  • 23,696
  • 23
  • 72
  • 146
1 2
3
13 14