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
2 answers

NullPointerException while calling AsyncTask.onPreExecute()

I am new to this site. I have an error with my AsyncTask and my android program... this is the first async task that I have written. The main Class called SocialApp.java @Override public void onCreate(Bundle savedInstanceState){ …
Mathew Kurian
  • 5,949
  • 5
  • 46
  • 73
2
votes
2 answers

Android Async Task stop running after run it a few times

I'm using using AsyncTask to download data over internet and I have a little problem. I need to be able to start one AsyncTask a few times, that's why I'm creating a new instance everytime,but the thing that I notice is that it's working without any…
Android-Droid
  • 14,365
  • 41
  • 114
  • 185
2
votes
1 answer

AsyncTask and Monitors

Here is my problem: I need to do several requests on a server. These requests have to be made one after the other in order to avoid mixing. For that, I'm using monitors. Here is what I've come up so far: public class TestActivity extends Activity { …
SteeveDroz
  • 6,006
  • 6
  • 33
  • 65
2
votes
0 answers

ListView - ListView don't update

I'm trying to do Autogrowin/Endless ListView but I have a problem with ArrayAdapter = update after downloading the data. public class ListShowActivity extends ListActivity { private ShowsAdapter m_adapter; private ArrayList
darkus
  • 21
  • 1
2
votes
1 answer

How to apply async task into this

After a few hours of trying I still cannot figure out how to incorporate an asynctask into the below code. I have tried threading which didn't work either. All I want to do is to run the scan in the background and show a progressbar. /** Called when…
xAnGz
  • 127
  • 4
  • 11
2
votes
1 answer

Android invoke asynctask from whole application

I need a little information/help/suggestions how can I build my application so I can use one AsyncTask from all activities which will download some data over internet. The problem is that once I run the asynctask from one activity, I want to…
Android-Droid
  • 14,365
  • 41
  • 114
  • 185
2
votes
1 answer

Loading Image using AsyncTask

I am trying to create a custom List Adapter which has an Image for every item it needs to download from the internet. When I first enter the Activity - the app freezes for a while till the images are downloaded and then the Activity List is loaded.…
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
2
votes
3 answers

how to change background image periodically in android

in my app in android, i need change background image in image view on 10 seconds once. so that i call a Async Task within a run method. when I execute the app it crashes. It gives the Caused by: java.lang.RuntimeException: Can't create handler…
M.A.Murali
  • 9,988
  • 36
  • 105
  • 182
2
votes
1 answer

Android - How to handle AsyncTask timeouts?

In my app, I use AsyncTask classes to make HTTP connections and download information to display. Sometimes, the amount of data is substantial and takes some time. If a user and their phone happens to be in a place with slow/poor/spotty reception,…
Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
2
votes
1 answer

How do I query a cursor in another activity from AsyncTask?

I have an AsyncTask called from Activity1 and Activity2 that is visible now. From Activity2 I am making some changes in the running AsyncTask and AsyncTask must requery cursor in my Activity2. How do I verify that Activity2 is visible and requery…
Sviatoslav
  • 1,301
  • 2
  • 17
  • 42
2
votes
3 answers

Is there a way to get Async Task to return data, or be able to send a param with a method to call after

I have an async task class that acts as a wrapper for http requests. I want to be able to either return the data from onPostExecute or somehow specify a method to send that data to after. I can't just call the function explicately because different…
Brian
  • 4,328
  • 13
  • 58
  • 103
2
votes
4 answers

How use ProgressDialog and Async Task get Method simultaneously

I have generic async task class which fetches response from server . And i receive those response by using get method . Now i knw that UI thread is block when i use get method , bcoz of which my progress Dialog doesnt showup on time . Now can…
Code_Life
  • 5,742
  • 4
  • 29
  • 49
2
votes
2 answers

What to use to perform a network operation in the background?

I am performing a network operation from a BroadcastReceiver. This operation is being performed in the background and the app will not be running when this happens. Which is better to use? A Service or an AsyncTask?
2
votes
4 answers

Error with ArrayAdapter in AsyncTask

I have the following code but I get an error on this line “userSpinner.setAdapter(adapter);” private class Task extends AsyncTask { protected void onPreExecute() { showDialog(DIALOG_TASKING); } …
user903601
2
votes
2 answers

Asynctask API call issue

I'm currently using an AsyncTask to make an API call and populate a list with data. I have a Sub Menu whose items can call the AsyncTask to populate the data, problem is that if i click quickly i end up with merged results obviously cause the…
1 2 3
99
100