0

I have large amount of pictures in server and need to show up in android app as list view. I tried storing just Url in db, but while retrieving from server it gives an error because of using more number of async task. Any suggestion with regard to this, As it would be useless if i store so many images and if i dont do that, its affecting user experience.

prashanth
  • 131
  • 2
  • 3
  • 11
  • A little more detail please. How many pictures are you trying to retrieve at once? Does your code work if there are only a few images? What error message(s) are you getting? How have you coded the async task? – Ted Hopp Sep 19 '12 at 00:44
  • I am Using twitter api to retrieve images of the followers of a person. So it can be N number of images depending on how popular he is :). IF i had only few followers like 4-5. It works fine.. and if its more than 15 it throws up error. – prashanth Sep 19 '12 at 00:46
  • error is 09-18 16:45:38.894: E/AndroidRuntime(764): java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@409f3f50 rejected from java.util.concurrent.ThreadPoolExecutor@4066fa40[Running, pool size = 128, active threads = 128, queued tasks = 10, completed tasks = 106] – prashanth Sep 19 '12 at 00:49

2 Answers2

1

You should not fire up a separate AsyncTask for each image. I suggest that you use a single AsyncTask to retrieve all images, one (or a few) at a time. As each image is received, the AsyncTask can use publishProgress (you will need to override onProgressUpdate) to display it in the UI.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
0

Are you making use of lazy-loading? Whenever you need to load a large, indeterminate number of images it's commonly advised to use lazy loading to both improve user-experience and to solve memory management issues.

Read/watch the following links:

Lazy load of images in ListView

http://www.youtube.com/watch?v=gbQb1PVjfqM

Community
  • 1
  • 1
A Random Android Dev
  • 2,691
  • 1
  • 18
  • 17