尝试从URL显示图像时无法解码流:fileNotFoundException [英] Unable to Decode Stream: fileNotFoundException when trying to show an image from URL
本文介绍了尝试从URL显示图像时无法解码流:fileNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码
{
@SuppressLint("NewApi")
public static Bitmap getbmp(String src)
{
Bitmap bm = null;
try ( InputStream is = new URL( src ).openStream() )
{
bm = BitmapFactory.decodeStream( is );
}
catch (IOException e)
{
e.printStackTrace();
Log.e("Exception",e.getMessage());
return null;
}
return bm;
}
}
然后我称它为
无法解码流:fileNotFoundException
Unable to Decode Stream: fileNotFoundException
推荐答案
尝试一下:
bm = BitmapFactory.decodeStream((InputStream) new URL(src).getContent());
这篇关于尝试从URL显示图像时无法解码流:fileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文