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

How to add data to custom BaseAdapter for listView - Android

I have a custom BaseAdapter class that creates views for comments, usernames, and numbers. This BaseAdapter receives this information from An AsyncTask. The AsyncTask runs when the user reaches the bottom of the listView. The problem is the…
user2544045
3
votes
1 answer

Android Asynctasks , passing String between activities

I am trying to pass a string(locationSet) set by a spinner from one activity to another, they both implement an Asynchtask within each class. I am unable to pass the value from the MainActivity to my WeatherActivity. Using the log, I can see the…
3
votes
2 answers

Avoid locking the screen while ProgressDialog is displaying

I want to show a progressBar while some instructions execute in background, but I don't want to lock the screen. This code is locking the screen: private class ConvertDataInBackground extends AsyncTask { private…
Ali
  • 9,800
  • 19
  • 72
  • 152
3
votes
1 answer

Fragment layout loading delay

As per the answer here How to make fragments load faster? I put all tasks in an async task and still there's a delay while loading fragment. The fragment is a calculator, with 30 buttons and two text views. I have a sliding drawer and the delay…
3
votes
1 answer

clap sound detection in android

I've searched StackOverflow and the web for many questions on whistle detection, etc, and many people did explain as much as they could as to how they can go about detecting their stuff. Detect Whistle sound in android Detect the beginning of a…
Susomrof
  • 234
  • 5
  • 21
3
votes
2 answers

Waiting for AsyncTask to get data and doing something in UI thread after that

I create a AsyncTask instance that calls a web service, gets Data and converts that to string. I want to update some picture based on the string taken from AsyncTask. (String includes some image URL I want to download if they aren't already exist in…
Alireza Farahani
  • 2,238
  • 3
  • 30
  • 54
3
votes
1 answer

Android stop asynctask

I have created an asynctask to show progress dialog while ghetting the users location. I want to run this asynctask for 30 seconds and if in these 30 seconds I haven't found the users location I would like just to kill the task and show an error…
Karlis
  • 1,501
  • 4
  • 19
  • 31
3
votes
2 answers

AsyncTask stops application

I'm using AsyncTask in my application, but when it starts, it's like that it never ends. When I'm debugging after doInBackground application freezes and stuck in ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker). Here's the structure of my…
nabroyan
  • 3,225
  • 6
  • 37
  • 56
3
votes
1 answer

Android AsyncTask's onProgressUpdate not working

I have an AsyncTask in a class. I want it to display the progress while it is getting executed. But it is not printing the Logs. private void registerBackground() { new AsyncTask() { @Override protected…
Pramod Ravikant
  • 1,039
  • 2
  • 11
  • 28
3
votes
5 answers

add view (text view) in AsyncTask

I used below code for add text view in Async task but : 07-26 11:40:39.302: E/AndroidRuntime(26715): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception 07-26 11:40:39.312: E/AndroidRuntime(26715): java.lang.RuntimeException: An…
user2536596
3
votes
1 answer

Cannot send login request to the server

Log cat error: 07-26 05:36:53.271: E/AndroidRuntime(2435): java.lang.NullPointerException 07-26 05:36:53.271: E/AndroidRuntime(2435): at com.example.servercommunication.tcpSocket.SendMessage(tcpSocket.java:135) 07-26 05:36:53.271:…
Rameshbabu
  • 611
  • 2
  • 7
  • 21
3
votes
2 answers

Calling an AsyncTask twice behavior

I am trying to implement a search bar that automatically searches as you type. My idea is to have an AsyncTask which fetches the search data from the server, but I can't figure how exactly AsyncTask will behave with my use of it. Let's say I have…
Michael Hoyle
  • 249
  • 2
  • 9
3
votes
2 answers

AsyncTask Open Camera

I've an activity that uses full screen SurfaceHolder, opening camera for preview (based on zxing code). Starting this activity results slow (1.x second), I think because of the heavy lifting of the camera manager. I'm using onResume method; is it a…
Jumpa
  • 4,319
  • 11
  • 52
  • 100
3
votes
3 answers

Updating progress on progress dialog from AsyncTask can't build

I can't build my project because eclipse giving error Here is button click event who starting download button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ProgressDialog mProgressDialog; …
darkanzali
  • 85
  • 1
  • 1
  • 10
3
votes
4 answers

How to use AsyncTask properly to avoid a slow UI?

On my UI, I have an ImageView (an arrowhead image) that needs to be updated in real time. There are 2 possible movements of the arrowhead: rotating to always point to the North moving when the user's location has changed I have already got these 2…
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174