asynctask

Switching to landscape orientation is slow

This is getting called in onCreate(), how can I speed up orientation switching? private void setupChartView(int position){ Quote myQuote = quotesAdapter.getItem(position); this.symbol = myQuote.getSymbol(); String url = "http://chart.finance.yahoo.com/z?s=" + symbol + "&t=1d&q=l&l=on&z=l&p=s&a=v&p=s&...

ProgressDialog not updating after Configuration Change (orientation turns to horizontal)

ProgressDialog quits updating when orientation of screen changes. I have put into place a fix that salvages the asynctask and sets the activity of the asynctask to the new activity after it is destroyed and rebuilt. The percentage complete on the progressdialog stays at the percentage it was at before the orientation change. What am I...

Android - list returns to top after update

I have a list that gets refreshed every 2 seconds via the Handler postDelayed() method. Every 2 seconds an AsyncTask is run that makes an HTTP GET request, turns the JSON into a list of objects, then sets the ListAdapter: MyListAdapter adapter = new MyListAdapter(someObjects); setListAdapter(adapter); My problem is that every time ...

Force close when tying to use BetterAsyncTask in droid-fu Android

Hi I am currently trying to use the android library android fu to help me with my first proper app. I am trying to makea test project using the droid fu library but when ever i go to test the app it force closes. I have used an example of the asynctask and when i test the app it loads and does what its meant to but when i replace it ...

How can I make asynchronous URL connections on Android?

I am using the following class to connect to my web service. I would like to make this asynchronous. How can I do this? package org.stocktwits.helper; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.apache.http.HttpEntity; import org.apache.http.HttpRe...

Problem returning an object from an AsyncTask

I have a class (RestClient.java) that extends AsyncTask: package org.stocktwits.helper; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; i...

AsyncTask doesn't run sometimes despite state being RUNNING?

In my application I use an AsyncTask on start up of my Activity to fetch the ringtone of a particular contact. It works normally but I have noticed that if the application is stopped twice before the AsyncTask gets to the doInBackground method then when the Activity starts again the AsyncTask fails to run properly, only getting to the o...

AsyncTask to run on Activity start fails after previously getting cancelled

I am using an AsyncTask to fetch the ring tone for a contact when my application starts, it works fine until after my Activity closes a couple of times during the AsyncTask, after this happens the AsyncTask will only ever get to onPreExecute() and never doInBackground, so I can never fetch the ringtone then until either a force stop or d...

Asynctask Error Handling

I am using AsyncTask to perform some background calculations but I am unable to find a correct way to handle exceptions. Currently I am using the following code: private class MyTask extends AsyncTask<String, Void, String> { private int e = 0; @Override protected String doInBackground(String... params) { try ...

How to run a retry when download fails in AsyncTask using AlarmManager

Hey guys, I use an AlarmManager to run a Service which tries to download a file from the web. If it fails I'd like to retry that Service in 5 minutes. Inside the Service I run an AsyncTask to run my code. As far as I know the only way I can tell if it failed or not is from the onPostExecute(). What is the best way of implementing a re...

How to handle notifications in an Android Activity

I have an Activity that will query a RESTful API every x seconds (polls using a handler). The results of the GET are used to update a ListView. This is done using an AsyncTask. I want to put a Notification in the Notification bar when certain criteria are met in the new data. Everything I have read up to this point has suggested that...

AsyncTask preformance issue on many AsyncTasks spawning.

Hi, I'm about to create a lazy image loader for images both from device and from the web for a ListView. I'm thinking of what to use and how, on one hand i can use a thread that pools my request (always running, and i can attach a view and an adapter and it will handle the image loading for me), cache my allready loaded images and checks...

How to use AsyncTask to show a ProgressDialog while doing background work in Android?

Hi, I am developing my first Android App and I need a ProgressDialog to be showed while a background task, in this case just a http call on the server, happens. I did a bit of studying on this and also have already checked other threads related to this subject. http://developer.android.com/reference/android/os/AsyncTask.html http://...

Progress dialog wont show with async task

I have been searching for an answer for this for some time now. I have an async task that downloads the database needed for my app, while this is downloading my app cant do anything as all the data it references is in this file, i have the app waiting for the file to be downloaded but i am attempting to show a progress dialog so the user...

Help with Async task, crashes on .execute()

Hello, when my Async task is executed it completely crashes the app Here is the code to the class. It sits inside of my main activity class. I'm new to threading, so sorry if I've done something ridiculous lol, I don't fully understand it. EDIT: private class TeamSearchTask extends AsyncTask<String,Void,Void> { CharSequence nf...

Asynctask taking ridiculous amount of time

Hello, My problem is that I had a program working before, without threading, and it took a long time to process info (16 seconds to get XML data and display it). Now I've gotten the whole threading and async thing down, but for some reason it is making my program SLOWER (in the emulator, device is not available right now), is there anyt...

asynctask in Android

Hi Team! Can anybody tell about the "asynctask" used in android application. Currently I am working on an application where I have to create a Class in which I have to just get the response of any particular URL given. I this particular class I was told to perform this task by making use of "asynctask". I had been getting very quick r...

Can I pass different types of parameters to an AsyncTask in Android?

I want to implement a generic, thread save class which takes the RessourceId of an ImageView and the Url (http) where the desired image file is stored. It'll download the image and fills the src of the ImageView in the UiThread. I thought AsyncTask would be the best thing for me. However I noticed that I only can pass one type of parame...

Do I still have to pass the ActivityContext to the AsyncTask in order to manipulate Views?

This function runs on the UiThread, but it seems that doesnt mean it also has access to the activity context. Shall I implement to my AsyncTask a public Setter to pass the activity (as reference)? protected void onPostExecute( Bitmap bitmap ) { //following is underlined red due to missing context (ImageView)findViewById...

Where to place the Asynctask in the Application

Hi Everybody! I wonder where to place the AsyncTask in the Application? Can I place it in onCreate Method of my Main Activity? Can anybody please tell me where I can place the Asynctask method in the Application? Thanks, david ...