当我调用这个方法时,我总是得到NULL的响应,但假如我在浏览器中运行它,它会显示图像。 URL myFileUrl = null;无法在android下载图像
try {
myFileUrl = new URL("http://www.russiawear.com/components/com_virtuemart/shop_image/product/youth_russia_usa_4e2f7f78b543c.jpg");
HttpURLConnection conn = (HttpURLConnection) myFileUrl
.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
bmImg = BitmapFactory.decodeStream(is, null, options);
return bmImg;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}`
什么可以是问题?
嗨吉利,请看看我发布这个问题时? – 2012-05-09 12:25:23
@NandlalVirani - 上面的评论是否提到这个问题是两个月大的事实?你从来没有接受过这个问题的答案,所以让其他人继续回答它似乎并不奇怪。如果您自己确实找到答案,请考虑将其作为回答并接受,以便其他人不会尝试解决您已解决的问题。 – 2012-05-09 13:23:37