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

How to make a blocking Android HttpRequest

Here is my issue: I have a list of values which I retrieve from server. These values fill ListView in the UI. I cannot continue loading the View and showing it to user until the list is full. Since Android forces me to make http calls in separate…
Gal Blank
  • 2,070
  • 2
  • 18
  • 18
2
votes
2 answers

Callback from an Async within a function library

I'm putting together my first Android application, which is also my introduction to the Java programming language, and so I'm stumbling over what may be some very basic concepts. My plan is to set up a server full of php functions and place all the…
Greg
  • 83
  • 5
2
votes
3 answers

AsyncTask, HttpClient and ProgressDialog

I'm creating a AsyncTask to login user to a server. The login works fine, but the ProgressDialog does not show until the end of the process. As soon as the user taps the button, the UI freezes, and my dialog does not show up. I appreciate any help.…
Felsangom
  • 1,522
  • 1
  • 10
  • 12
2
votes
1 answer

Android background thread management and activity lifecycle

I have an activity in which I collect data for an online transaction. When the collection is done, I run a background thread (more specifically an AsyncTask) that calls a web-service and waits for its response, then return it to the activity.…
Vincent
  • 1,027
  • 1
  • 11
  • 20
2
votes
2 answers

How to parse an xml file while pausing main execution but not the UI

I need to parse an xml file which takes about 3 seconds, and immediately use the data that is parsed from the xml file after it has completed. However, since it takes around 3 seconds to complete, i don't just want the screen sitting and waiting for…
user1154920
  • 465
  • 1
  • 6
  • 21
2
votes
2 answers

onCreate method keeps getting called when the orientation of device changes

I have an AsyncTask which gets called onCreate() in my Main Activity. In the same Activity if the orientation changes the AsyncTask gets called again. How do I prevent this from happening or how do I restructure my program to avoid this…
2
votes
1 answer

block android back button while Asyn Task Execute

When my app gets launched i am calling a Asyn Task function. In the background process its hitting 3 APIs and their parsing functions goes on, It will be taking around 10 minutes of time. In that case if the user clicks on the android default back…
Siva K
  • 4,968
  • 14
  • 82
  • 161
2
votes
4 answers

is this asynctask correct?

I have my first class, its a loading screen. public class Loading extends Activity { public int switchscreensvalue = 0; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
codesomethin
  • 195
  • 1
  • 3
  • 11
2
votes
1 answer

how to create Asynctask to load sounds into a manager on a loading screen

My past two questions were short and not detailed so I'll try my best this time. I have a large soundboard with around 430 sounds. It is so big, I have to create 2 soundmanagers on some devices. Anyway, on the loading screen, I am trying to…
codesomethin
  • 195
  • 1
  • 3
  • 11
2
votes
2 answers

Guidance on using a SynchronousQueue

I need to perform a series of http requests, each of which may depend on a previous http response. I have been able to achieve this using an AsyncTask "tree" of sorts, but as the decision tree grows, the AsyncTask technique grows more unwieldy. I…
aez
  • 2,406
  • 2
  • 26
  • 46
2
votes
2 answers

sequencing asynctasks

I understand that http requests should be run as part of an AsyncTask to keep it off the the UI thread. But what about the case where multiple and sequential http requests may be necessary, where the latter http requests depend on the earlier, and…
aez
  • 2,406
  • 2
  • 26
  • 46
2
votes
2 answers

Android Add AsyncTask to PreferenceActivity to load a lot of preferences the first time

I have an application with quite a lot of preferences. So when the user loads the Preferences the first time, it takes quite a while. So the UI is freezing while loading the prefs. This is why I want to add a dialog telling the user that the prefs…
JoachimR
  • 5,150
  • 7
  • 45
  • 50
2
votes
2 answers

Refresh ActionBar from an AsyncTask

I have a ListView Activity that uses a AsyncTask to load data from the database. This Activity has an options menu that checks to see if there are any data items in the Activities ListView in onPrepareOptionsMenu(). If there are items, I enable one…
Unpossible
  • 10,607
  • 22
  • 75
  • 113
2
votes
1 answer

AsyncTask never executing doInBackground (but does in debug) (Update: Fixed)

Fixed: Turns out the problem was that I was clearing the ArrayList after passing it in to the Task, so by the time it got around to executing it, there was nothing there to send. It was working in debug because it could execute before I let it step…
cmcowart
  • 193
  • 1
  • 13
2
votes
1 answer

the postExecute method of AsyncTask not working properly

If I run above and below code in separate projects, it works. But when I try integrate them, the graph is not getting populated. The reason I feel is in postExecute method because One important thing to notice is when I run any other random project,…
GAMA
  • 5,958
  • 14
  • 79
  • 126
1 2 3
99
100