Question about AsyncTask performance

Put your problem here if it does not fit any of the other categories.

Question about AsyncTask performance

Postby spengilley » Wed Jan 19, 2011 10:47 am

Hi all,

I have a question about the AsyncTask.

I have a simple activity which loads a picture into an ImageView.

I wanted to have a progress dialog show in case it took a while to find and display the photo on older phones. I checked out various ways of implementing a thread and the AsyncTask seemed to work best in my situation. I got it working but there was a definite delay in getting the photo via the AsyncTask + a handler to add the bitmap returned via teh asynctask to an ImageView. It turns out that on my phone simply getting the photo in the UI thread works faster.

So is this performance issue inherent with using AsyncTask? If no, I can post my code to see if it is something else that I have done.

Many thanks for your replies
spengilley
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Sep 07, 2010 9:14 pm

Top

Re: Question about AsyncTask performance

Postby m1shk4 » Wed Jan 19, 2011 4:37 pm

Take a look at the Handler vs AsyncTask discussion on stackoverflow
m1shk4
Developer
Developer
 
Posts: 38
Joined: Wed Jan 12, 2011 4:26 pm
Location: UA

Re: Question about AsyncTask performance

Postby jonbonazza » Wed Jan 19, 2011 7:57 pm

Do yourself a favor and look into the Thread class... It's a bit more complicated, but MUCH more powerful. It still requires the use of Handlers, so you will need to look into those as well. The AsyncTask class is a joke.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: Question about AsyncTask performance

Postby spengilley » Thu Jan 20, 2011 3:29 pm

Thanks for the responses guys. I will test using a thread with a handler also to see which works best
spengilley
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Sep 07, 2010 9:14 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 26 guests