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

pass ArrayList> in AsyncTask

I did a bit of mistakes and I do not know how to get out. Originally, the code is this and it works: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); …
Valkyrie00
  • 51
  • 1
  • 7
3
votes
1 answer

Opening Camera using AsyncTask

I want to use AsyncTask to open the camera as suggested here http://developer.android.com/reference/android/hardware/Camera.html#open%28int%29: Caution: On some devices, this method may take a long time to complete. It is best to call this method…
3
votes
2 answers

Can't dismiss ProgressDialog after the AsyncTask complete

Please help, I can't dismiss ProgressDialog after AsyncTask complete. I searched for the answer but nothing found. This code works fine when I use Thread instead of AsyncTask. Have any ideas? Context appContext; ProgressDialog pd; @Override public…
Boleslav
  • 35
  • 2
  • 6
3
votes
1 answer

Android AsyncTask: Skipped X frames - too much work inside main thread

I am making some RSS reader for some website, so I wanted to implement actionbar and viewpager on lower versions of Androd that 4.0, so I am using ActionBarSherlock and ViewPagerIndicator from Jake Wharton, so I am working with fragments. And I want…
Zookey
  • 2,637
  • 13
  • 46
  • 80
3
votes
1 answer

Adding multiple markers to Google Maps API v2 from List array with the helping of AsyncTask

My app requires adding of hundreds markers (in some cases). For this I am using "for loop" which seems to be not bad solution if I am using default markers. I need to use custom image for each marker which I am downloading from the internet with the…
3
votes
1 answer

Android FTP connection Failed

I am trying to use FTp to connect the server and download the file but the conection fails at the Android , but when I try to connect the FTP using FileZilla or the Windows File Explorer , it works. What is the reason behind ? the below is my code…
Jeff Bootsholz
  • 2,971
  • 15
  • 70
  • 141
3
votes
4 answers

pass parameter to AsyncTask

I am build android app which is supposed to open barcode scanner screen and scan the barcode, then send the barcode string to a webservice. I have done barcode reading part, sending static strings to webservice. I am sending strings to webservice…
Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189
3
votes
3 answers

AsyncTask and JSON, onSuccess doesn't return anything

I'm here with another question. I post you the code from my AsyncTask function to get values from a JSONObject (webservice). My problem is that I have a List and I fill this list with the data from the json in the onSuccess method, but later, in the…
Víctor Martín
  • 3,352
  • 7
  • 48
  • 94
3
votes
2 answers

How to run an AsyncTask after another?

I'm trying to run them two AsyncTask sequences and does not work, it only runs the first. If I change the order of the AsyncTask, as only runs the first, the second is not, then the TimerTask if running. Look at my code: (Excuse my language, I speak…
Heberth
  • 615
  • 6
  • 16
3
votes
2 answers

performance wise, what is better: AsyncTask or simply create a runnable?

I am currently working on an Android project which loads a lot of pictures onCreate. To make sure the UI doesn't get blocked I have the option to put it in a runnable or an AsyncTask. What is (performance wise) the better option or is it practically…
Bart Burg
  • 4,786
  • 7
  • 52
  • 87
3
votes
3 answers

Android AsyncTask SoapObject Request Issue

I want to use .net web service in my android app. I send request to web service by using asynctask. But request doesn't take value properly. I used this structure in many android apps and I never got error like this. What is the problem? I have…
3
votes
1 answer

How to start an AsyncTask on ActivityResult and show on MainActivity

I open an intent for capture an image and OnActivityResult i call an AsyncTask to start to make some processing to the image. The problem is that i want to load first the mainActivity and then start the AsyncTask in order to see the percentage of…
3
votes
1 answer

Stop AsyncTask doInBackground method

I have created an AsyncTask in a class and i am calling that task from a fragment. The problem is i want to stop the doInBackground method if the fragment is destroyed. To do that i created a method in the class where AsyncTask is written and i used…
Ravi
  • 4,872
  • 8
  • 35
  • 46
3
votes
2 answers

Google Maps API V2 addMarker and OnCameraChangeListener

Scenario Initial user position is read and a marker is added + camera position is set to that location. Each time the user drags/zooms the camera I need to call a web service and pass the rectangle coordinates of the map. This web service returns a…
Alin
  • 14,809
  • 40
  • 129
  • 218
3
votes
1 answer

Android Refreshing Fragment View after AsyncTask

I am trying to update list fragment when an AsyncTask in my activity completes but I am not sure if I am doing something wrong. Currently, I have a button that initiates the AsyncTask: search = (Button)findViewById(R.id.search); …
user2352691
  • 33
  • 1
  • 1
  • 3