Questions tagged [android-asynctask]

Use for questions on android.os.AsyncTask

AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

AsyncTask is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework. AsyncTasks should ideally be used for short operations (a few seconds at the most).

WARNING : The AsyncTask has an implicit reference to the enclosing Activity. If a configuration change happens the Activity instance that started the AsyncTask would be destroyed, but not GCd until the AsyncTask finishes. Since Activities are heavy this could lead to memory issues if several AsyncTasks are started. Another issue is that the result of the AsyncTask could be lost, if it's intended to act on the state of the Activity. Replace the AsyncTask by the new AsyncTaskLoader

More information:

14544 questions
3
votes
3 answers

Handle single progressdialog with parallel multiple asynctask

In my Project I want to parallelly load the data from 3 different url's(webservice) while loading the page. for this I use 3 different asynctask to load data. I want to show the progress dialog message as "loading" when first asynctask is started…
Krishna Prasad
  • 693
  • 1
  • 6
  • 19
3
votes
1 answer

Partial order: AsyncTask.get() and onPostExecute()?

I'm instantiating and executing an AsyncTask from my UI thread (in the onCreate() handler of my Activity). I guarantee that the Activity doesn't restart due to config changes (it ignores orientation change, for example). In my Activity.onCreate(): I…
Thomas Calc
  • 2,994
  • 3
  • 30
  • 56
3
votes
3 answers

Populating listview in separate thread

In an activity I load rows of a listview which takes much time, therefore I put this task in a separate thread to allow displaying a progressDialog. I do the following private void doMyStuff() { listItems.clear(); progressDialog.show(); …
HpTerm
  • 8,151
  • 12
  • 51
  • 67
3
votes
2 answers

AsyncTask and generics

I am using AsyncTask as an inner class with the following signature as below: public abstract class BaseFragmentActivity extends FragmentActivity { static final int PROGRESS_DIALOG = 0; Dialog progessDialog; public abstract void…
sab
  • 9,767
  • 13
  • 44
  • 51
3
votes
2 answers

using AsyncTask to display data in ListView

I need me a little help. I need to use asynctask to display data in ListView. But I don't know how becouse I'm new in Android programming ... thank you very much for any help. public class Main extends ListActivity { Button buttonbg; /** Called…
Nenad
  • 33
  • 1
  • 1
  • 3
3
votes
2 answers

ListView adapter getView() not called if populated after onCreate()

I'm having a rather puzzling problem. If I try to populate a ListView with an AsyncTask, getView() on that ListView's adapter is never called. Note that this is the initial population of data for this ListView when the Activity starts. The AsyncTask…
Nishmaster
  • 525
  • 3
  • 10
3
votes
1 answer

Android - AsyncTask Socket Write Timeout

I have a background alarm running every minute using the example posted here: Alarm Manager Example My actual alarm launches an AsyncTask (since I am doing a network transaction), that looks like this: Socket sock = new Socket("hostname.com",…
xur17
  • 506
  • 1
  • 8
  • 24
2
votes
1 answer

Is android async task slow?

Is android async task slow or am i doing something wrong? Here is what i do Log.e("Filler", "before"); new DownloadListContent().execute("string"); Log.e("Filler", "after"); and DownloadListContent().. class DownloadListContent extends…
weakwire
  • 9,284
  • 8
  • 53
  • 78
2
votes
2 answers

async task 2 functions running in doInBackground

Hello I want to use async task and this is my sceleton code: public class MyActivity extends Activity { private ProgressDialog pd = null; private Object data = null; public void onCreate(Bundle savedInstanceState) { …
qwerty_gr
  • 318
  • 3
  • 7
  • 15
2
votes
2 answers

AlarmManager is blocking main thread

I have implemented an AlarmManager which calls a Service. The problem is that although I'm launching it in AsyncTask, it's blocking the main thread. This is the source of my AsyncTask: private class NotificationsServiceTask extends AsyncTask
Alex
  • 6,957
  • 12
  • 42
  • 48
2
votes
3 answers

Android ListView not updating after a call to notifyDataSetChanged

I have an Activity which I start like this: public class MyProblemsActivity extends ListActivity { String[] PROBLEMS = new String[] {"One", "Two", "Three" }; ArrayAdapter adapter; /** Called when the activity is first created.…
GeekedOut
  • 16,905
  • 37
  • 107
  • 185
2
votes
0 answers

Android media player in a service keeps causing ANR

I have a service that is supposed to stream audio using a media player the streaming happens fine but seems to happen in the UI thread even though am using AsyncTask *sample Code * package com.package.app; import android.app.Service; import…
zacck
  • 43
  • 9
2
votes
1 answer

populating listview through a fragment

I have a class extending listFragment. I have written code for fetching json response in a method which is called in oncreate of the class. For fetching json in background I have created new inner class which extends asyncTask. I can get the…
vivek
  • 45
  • 10
2
votes
2 answers

i get -1 length of file asynctask android download

I have a problem i get -1 as length of the file. I tried a lot of time to fix it. I don't know why this happens. Also when i call again the asynctask , song1 stays the same(but the song1 value have not any problem, i tested with a toast and it…
Jessy Jameson
  • 197
  • 2
  • 5
  • 15
2
votes
1 answer

Loading image bitmap from content providers using asynctask

I have been trying to query for all images on sd card through MediaStore content provider and display their thumbnail on a GridView. However, if i load the image thumbnail on the main thread, the scrolling gets incredibly slow... So i tried to load…