I'm developing an Android application which uses several images and I would like transfer bigger images (2-6 MB) on a web server to download them when need.
I've never tried it before so I've found a method which uses AsyncTask to download images on button click, is this the best solution?
Any better options or opinions?
EDIT: I'm trying koush's ion
EDIT 2: I tried ion (https://github.com/koush/ion) and I like it here very well, very easy to use. advised
-
I would suggest you Android Query for this task. – Pratik Dasa Aug 26 '14 at 07:03
-
1Try Universal Image loader. https://github.com/nostra13/Android-Universal-Image-Loader – nnesterov Aug 26 '14 at 07:03
-
2I recently switched from Universal Image Loader to Google's Volley library. It's way faster. I definetly recommend it. – stanete Aug 26 '14 at 07:04
-
Check : http://stackoverflow.com/questions/2471935/how-to-load-an-imageview-by-url-in-android/24134425#24134425 – Haresh Chhelana Aug 26 '14 at 07:09
-
I recommend Ion library https://github.com/koush/ion – MAY3AM Aug 26 '14 at 07:14
-
Thank you guys I'm checking the links, I'll update thread if there are other question\problems. – Aug 26 '14 at 07:22
-
Do not use Universal Image Loader - It is slower than other libraries. Try Picasso or Google's Volley. – Yuraj Aug 26 '14 at 09:59
5 Answers
Use Universal image loader for downloading images asynchronously.
[https://github.com/nostra13/Android-Universal-Image-Loader][1].
The Library itself has a sample code to download image.you may refer it..
[1]: https://github.com/nostra13/Android-Universal-Image-Loader
After downloading library add library with your project and insert the below code at necessary place
String final_url="www.google.com/.....";
ImageView image;
ImageLoader imageloader = ImageLoader.getInstance();
imageloader.init(ImageLoaderConfiguration.createDefault(context));
DisplayImageOptions options; = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.ic_empty)
.showImageOnFail(R.drawable.ic_error)
.resetViewBeforeLoading(true).cacheOnDisk(true)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
.cacheInMemory(true)
.displayer(new FadeInBitmapDisplayer(300)).build();
imageloader.displayImage(final_url, image);

- 1,112
- 1
- 11
- 23
I strongly recommend to use Glide or Picasso, which are the most used libraries nowadays. Just google "Glide for Android" or "Picasso for Android" and they take care of the threading, caching, optimization, etc. I hope it helps!

- 1,295
- 11
- 21
Best practice: http://developer.android.com/training/displaying-bitmaps/index.html. Useful libraries: Picasso - http://square.github.io/picasso; Glide - github.com/bumptech/glide.

- 176
- 4
Actually the most important reason to useAsyncTask
is that you want a mechanism to do a lengthy operation with out blocking your UI. With it you also get rid of managing child thread and synchronization. And that's it. If you want other functionalities, such as bitmap caching, you will have to implement on your own or use some third-party tools.

- 3,300
- 1
- 17
- 34
Use lazy loading images for this and use image caching.This is the best way to do it.
https://github.com/thest1/LazyList
http://sunil-android.blogspot.in/2013/09/lazy-loading-image-download-from.html
You can find some more examples for lazyloading.Hope the above links are also useful.

- 4,397
- 11
- 43
- 71