由网友(拼一个春夏秋冬)分享简介:我想知道是否有可能使用BitmapFactory.de codeFILE的方法去codeA形象从HTTP位置? I would like to know if it is possible to use BitmapFactory.decodeFile method to decode a image from ht...
我想知道是否有可能使用BitmapFactory.de codeFILE的方法去codeA形象从HTTP位置?
I would like to know if it is possible to use BitmapFactory.decodeFile method to decode a image from http location?
有关,例如。
ImageView imageview = new ImageView(context);
Bitmap bmp = BitmapFactory.decodeFile("http://<my IP>/test/abc.jpg");
imageview.setImageBitmap(bmp);
不过,BMP总是返回null。
But bmp is always returning null.
有没有达到这种情况下任何其他方式,在那里我有一组图像在我的服务器电脑,我是通过XML加载图片到我的画廊的应用程序?
Is there any other way to achieve this scenario, where i have a set of images in my server PC, and i am loading the images to my gallery application via an xml?
谢谢, 森
推荐答案
@Amir和放大器; @Sankar:感谢您的宝贵建议
@Amir & @Sankar : Thanks for your valuable suggestions.
我通过以下操作code段解决了上述问题:
I solved the above problem by doing the following code snippet :
ImageView iv = new ImageView(context);
try{
String url1 = "http://<my IP>/test/abc.jpg";
URL ulrn = new URL(url1);
HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
InputStream is = con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
iv.setImageBitmap(bmp);
else
System.out.println("The Bitmap is NULL");
} catch(Exception e) {
}
谢谢, 森
Thanks, Sen
相关推荐
最新文章