Android: helper class for asynchronous images downloading with caching

Posted by Unknown Sabtu, 13 Agustus 2011 0 komentar


It's a common task in the Android development to display some images from the web into the ImageView widgets. Curiously enough, Android SDK doesn't have API for such a common thing, something like:
imageView.downloadFromURL(SOME_URL_HERE);

Moreover we want to have next features also:
  • perform data loading process in a separate thread to make User Interface responsive (while image data is loading)
  • caching support, to retrieve data immediately for already downloaded images  

Of course, we can write some kind of helper class for this common task: private AsyncTask subclass to perform data loading process in an asynchronous manner, some HashMap or LinkedHashMap based class for cache implementation, etc.

But there is one more way to get all required features of image downloader helper class and don’t spend extra efforts for its implementation! :) 


At the official Android Developers site there are a lot of different samples. And one of them is extremely useful in our case. Look at the XML Adapters sample:
It has sample Activity to retrieve an RSS photo feed and displays the images and their titles. So in order to retrieve RSS photos guys form Android development team wrote ImageDownloader class. And this class exactly fits all our requirements!

Here you can grab the source code of ImageDownloader class:





TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: Android: helper class for asynchronous images downloading with caching
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke http://androidillegal.blogspot.com/2011/08/android-helper-class-for-asynchronous.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android illegal.