[英]This image could not be downloaded in android. Why?
I use the following code to download images. 我使用以下代码下载图像。 All images can be successfully downloaded except one.
除一张外,所有图像均可成功下载。 This image http://www.dailydealster.com/system/illustrations/18089/original/18089s.jpg could not be downloaded.
无法下载该图片http://www.dailydealster.com/system/illustrations/18089/original/18089s.jpg 。 Any one experience such a problem.
任何人都会遇到这样的问题。 While debugging the image is downloaded.
在调试时,将下载映像。 But at release mode, this image is not downloading
但是在发布模式下,此图像未下载
try {
ImageView i = (ImageView)findViewById(R.id.image);
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageUrl).getContent());
i.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
过去这对我有用。
i = Drawable.createFromStream(((InputStream) new URL(imageUrl).getContent()),"image_name.png")
I would be tempted to space out your retrieval code to something like this: 我很想将您的检索代码间隔成这样:
URL url = new URL(photoUrl);
URLConnection ucon = url.openConnection();
Bitmap bitmap = BitmapFactory.decodeStream(ucon.getInputStream());
ImageView image = (ImageView) findViewById(R.id.image);
image.setImageBitmap(bitmap);
This way you avoid using casting, making it a more robust approach and could potentially solve your problem. 这样,您可以避免使用强制转换,使其成为更可靠的方法,并有可能解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.