下载Android上的图像的最佳方法 [英] Best way to download images on Android

查看:222
本文介绍了下载Android上的图像的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发其在Web服务器上使用多个图像,我想传递更大的图像(2-6 MB)一个Android应用程序下载他们需要时。结果
我从来没有尝试过之前,所以我发现它使用的AsyncTask下载按钮点击图像的方法,这是最好的解决办法?_爱
任何更好的选择或意见?结果搜索结果
修改我试图koush的离子搜索结果
修改2:我试图离子( https://github.com/koush/ion),我喜欢这里很好,很容易上手。建议


解决方案

 使用通用图像异步下载图像加载器。  [https://github.com/nostra13/Android-Universal-Image-Loader][1]。
  图书馆本身具有样本code下载image.you可参考吧..
  [1]:https://github.com/nostra13/Android-Universal-Image-Loader
下载库在必要的地方添加库项目,并插入下面的code后
字符串FINAL_URL =www.google.com / .....;
ImageView的形象;ImageLoader的ImageLoader的= ImageLoader.getInstance();imageloader.init(ImageLoaderConfiguration.createDefault(上下文));DisplayImageOptions选择; =新DisplayImageOptions.Builder()
                .showImageForEmptyUri(R.drawable.ic_empty)
                .showImageOnFail(R.drawable.ic_error)
                .resetViewBeforeLoading(真).cacheOnDisk(真)
                .imageScaleType(ImageScaleType.EXACTLY)
                .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(真)
                .cacheInMemory(真)
                .displayer(新FadeInBitmapDisplayer(300))建立()。
imageloader.displayImage(FINAL_URL,图像);

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

解决方案

   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);

这篇关于下载Android上的图像的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆