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 asynchronous perform a httprequest and show the progress of downloading the response

I am trying to perform a http-get-request and show the download progress to the user. I am familiar with the concept of AsyncTask, I also know how to use URLConnection together with BufferedInputStream to download a file in pieces while showing a…
Thassilo
  • 309
  • 1
  • 4
  • 12
2
votes
1 answer

How to save state while using AsyncTask in a service?

I've been using AsyncTask for sometime and the biggest problem I face is that the app crashes a lot and the rendering happens way too many times. For example, If I set the data on a particular layout and render it, and then turn the screen, the…
Hick
  • 35,524
  • 46
  • 151
  • 243
2
votes
1 answer

Android APIs and methods that are version-specific

I'm working on a project that was originally designed for Honeycomb; we want to make it compatible with 2.3.3. I'm doing this by converting a copy of the original project to a library project, including this library into several new projects, and…
2
votes
1 answer

Is this the best way to implement AsyncTask? Or are there better ways?

I am trying to write a AsyncTask generic package. Till now, what I've done is call one activity from another send the instance in the Intent to that Activity. This activity is part of the AsyncTask which calls the AsyncLoader.execute() file. I am…
Hick
  • 35,524
  • 46
  • 151
  • 243
2
votes
2 answers

Should I use intent service?

I have a user login screen. The user presses a login button and I create an IntentService to connect to my rest services and return back a authentication result. Now here's the functionality I want to achieve: If the activity is paused (i.e. goes…
MobileMon
  • 8,341
  • 5
  • 56
  • 75
2
votes
3 answers

Exceptions in the doInBackground method

try { Get_Webpage obj = new Get_Webpage(url); directory_listings = obj.get_webpage_source(); } catch (Exception e) { finish(); m_ProgressDialog.dismiss(); Toast.makeText(this, "You have to be connected to the internet for this…
Nick Kahn
  • 19,652
  • 91
  • 275
  • 406
2
votes
1 answer

Async Task Data fetcher

I have one class that extends Asynctask. In this class I have a method that returns a hash map. How can I get this Hashmap in different class that extends Activity. Anyone give me some reference code?
Hardik
  • 1,429
  • 2
  • 19
  • 37
2
votes
1 answer

performing onclick action on listview inside a dialog box

in my app when i click a button showing a dialog box with listview. The list of items are been shown from an array list. Following is the bit of my code private void album_list_box() { Dialog dialog = new…
Siva K
  • 4,968
  • 14
  • 82
  • 161
2
votes
2 answers

Using asynctask in fragment

I have an asynctask in my fragment.Whenever i get in this fragment it loads all the data from the beginning but it's waste for me.So i want that it loads only one time.How can i fix this?
2
votes
3 answers

AsyncTask and the setContentView

I have this code for managing some countrys on my database; class checkCountryAsync extends AsyncTask { @Override protected void onPreExecute() { super.onPreExecute(); setContentView(R.layout.main); …
Milos Cuculovic
  • 19,631
  • 51
  • 159
  • 265
2
votes
1 answer

log affecting listview?

Quick question, I have a listview that's populated from a database through an AsyncTask. I use an if statement to decide which db method to get a cursor from. The db methods work great outside an asynctask, but only works inside the asynctask when…
Bill Gary
  • 2,987
  • 2
  • 15
  • 19
2
votes
1 answer

AsyncTask does not terminates

I started an AsyncTask. Every seems to be OK and I checked that I get to the end of the task in doInBackground. onPostExecute is called too. The problem is that I keep seeing in the list of the thread in Eclipse my AsyncTask and if I started again I…
user1175011
2
votes
3 answers

how to pass data between service and it's application in the right way?

i'm a newbie in android. In my app i create a many-to-many chat, and need to update from server a list of Messages. In order to do so, i created a service that updates every second from the server. My problem is that i don't know how to pass data…
2
votes
1 answer

Android Looper.prepare() and AsyncTask

Hi I have some questions regarding Looper.prepare() and AsyncTasks. In my app I have an AsyncTask that's starting other AsyncTasks. I had 2 AsyncTasks Search and GetImage. The GetImage task is executed several times within the Search task. It works…
triggs
  • 5,890
  • 3
  • 32
  • 31
2
votes
1 answer

Android Java AsyncTask isCancelled Issue

I have an app where I connect to a web service to retrieve data. I'm using AsyncTask to do this. Here is a piece of the code I'm using in doInBackground: publishProgress(user.dbsCode() + ": Retrieving Standard Comments"); if (!_sync.isCancelled())…
Chris
  • 91
  • 2
  • 7