我的代码是这样的,能够png没问题,但是jpg就返回null了
protected Bitmap getBitmapFromURL(String sUrl) throws IOException{
URL url = new URL(sUrl);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
return bm;
}
protected Bitmap getBitmapFromURL(String sUrl) throws IOException{
URL url = new URL(sUrl);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
return bm;
}
public static Bitmap getSingerImage(String urlpath)throws Exception {
InputStream inputstream;
URL url = new URL(urlpath);
//打开连接
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
//得到数据流
inputstream = conn.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputstream);
return bitmap;
}
虽然我看到你的帖子之前已经解决了,但给分,谢谢了。