Java BitmapFactory.decodeStream某个时间返回null
我有inputStream对象,当我尝试在位图中转换时,它可以工作,但对于某些图像,它仍然会返回null,图像存在Java BitmapFactory.decodeStream某个时间返回null,java,android,Java,Android,我有inputStream对象,当我尝试在位图中转换时,它可以工作,但对于某些图像,它仍然会返回null,图像存在 InputStream responseInputStream = apiResponseModel .getResponseInputStream(); if (responseInputStream != null) { Bitmap bmp = BitmapFactory.decodeStream(responseInputStream
InputStream responseInputStream = apiResponseModel
.getResponseInputStream();
if (responseInputStream != null) {
Bitmap bmp = BitmapFactory.decodeStream(responseInputStream);
imgProductProfile.setImageBitmap(bmp);
}
您尝试解码的图像可能不支持解码。Android只支持少数图像类型进行解码。此处列出了支持的格式
. 尝试将图像转换为其他格式,如PNG、JPG,然后尝试解码尝试使用
Options=new BitmapFactory.Options()
options.inJustDecodeBounds=true代码>BitmapFactory.decodeStream(responseInputStream,null,选项)代码>可能重复的不要忘记关闭()
您的响应输入流
此问题特定于设备。