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

getInstalledApplications() with asynctask

I am getting a list of installed non-system apps to show to the user and I am using this to do so: private class getApplications extends AsyncTask { @Override protected String doInBackground(String... params) { …
Jasonwilliams10
  • 292
  • 1
  • 4
  • 17
3
votes
1 answer

how to wait in asynctask class until its task completed

I am new to Asynctask coding, and am having some issues. In my code I have defined a subclass in an onClick listener, and in that class I have created an Asynctask which is using HTTP connections, and has some XML parsing code. The problem is, when…
Prasad
  • 121
  • 2
  • 12
3
votes
1 answer

AsyncTask usage

I have a question on using AsyncTask class provided by Android sdk. I am starting a task in my code from the activity whose work is to send emails periodically (as per the specified time). I restart the task in onPostExecute(). It does send email…
Adithya
  • 2,923
  • 5
  • 33
  • 47
3
votes
3 answers

Android AsyncTask vs. Threads for a specific case

I am working on an application that Looks similar to the Google Play App (swipe view with gridviews inside the fragments, in addition data in the gridview [image + text] is retrieved from a remote server). My problem is with background tasks. I…
3
votes
2 answers

Calling UI thread method from AsyncTask

I have a problem with calling the setadapter() method from the inside of AsyncTaskActivity onPostExecute() method. I've read docs about AsyncTask: http://developer.android.com/reference/android/os/AsyncTask.html#onPostExecute(Result) but found no…
XorOrNor
  • 8,868
  • 12
  • 48
  • 81
3
votes
0 answers

How to get data from asmx webservice?

I want to access the name of customers that is in red color box, in the picture above, but it do not gives me data, it shows only "anydata type( )" only one time. I do not know what is category name, this is dynamic. How to get data from this? …
3
votes
2 answers

Error java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 in Android adapter

I have a adapter which extends BaseAdapter in my activity. In adapter I list the records. When the user click any record, options are listed. These options are "send" and "delete". Delete options remove record from list and send option send record…
3
votes
1 answer

GridView Loads the duplicate images and Text (using EndlessScrollListener)

I have a custom gridVIew With an ImageView and a TextView in it, and I have set the gridView as a it show 2 coloumns. here is the code of custom_grid_layout.xml
Qadir Hussain
  • 8,721
  • 13
  • 89
  • 124
3
votes
1 answer

ASyncTask, hidden fragments, retaining instances, and screen orientation changes

My setup is as follows. I have a FragmentPagerAdapter called from my Activity which loads two fragments. This is setup within onCreate. In onResume I call an ASyncTask which loads data from a database, and then calls a callback in my activity…
3
votes
1 answer

AsyncTask onPostExecute is not called on 2.3

I have a piece of code running the background using AsyncTask. The code is similar to this: private class MyAsyncTask extends AsyncTask { public MyAsyncTask() { // Some init. code } @Override protected…
m.hashemian
  • 1,786
  • 2
  • 15
  • 31
3
votes
0 answers

httpclient.execute in httppost method is not working with emulator when using AsyncTask implementation

I am new to android and was trying an async task implementation for fetching some data from webservices APIs and it works fine with normal single thread (UI main) implementations. But on moving to AsyncTask for proper implementation and better UX,…
3
votes
1 answer

How can i return an arraylist from AsyncTask?

I have a problem is the following: I have to take some data from mysql from android, and for that I do it with php, but since I use android 4.0 put through an AsyncTask. The problem is that I don't know how to return the resulting arraylist.
Squall
  • 59
  • 9
3
votes
1 answer

Android: Improving audio performance running in service

I'm working on a music player for android, loosely based on the AOSP music player project. The audio runs in a foreground service, but I've found songs are occasionally 'skipping', small audible 'hiccups' in the tracks. Are there any other ways to…
3
votes
3 answers

How can I parse a JSON object and display it in a list view?

Below is the code I am having problems with. The php file works like a charm, as you can see if you go to the value the url_all_dates variable holds. Below this class is my .xml layout file for the list_item. The app runs but doesn't display any…
prayingmantes
  • 155
  • 1
  • 7
  • 19
3
votes
3 answers

Android: Filling ListView with ArrayAdapter in AsyncTask -> Shows only one item

I am filling a ListView with ArrayAdapter in an AsyncTask. But everytime it only fills in one item. Could someone explain me why? onCreate @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
Marco Seiz
  • 944
  • 5
  • 19
  • 40