我的代码是这样的,能够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;
}

解决方案 »

  1.   

    不能吧,我的都可以的
    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;
    }
      

  2.   

    2楼正确我的就是多了BufferedInputStream bis = new BufferedInputStream(is);
    虽然我看到你的帖子之前已经解决了,但给分,谢谢了。