开发者

Android: Getting Drawable from URL not working for .jpg, only works for .png

I am working on and Android app that pulls a picture from an internet page (specifically xckd.com). I have it working wonderfully using code of this basic form (see below)

ImageView iv = new ImageView;
    URL url = new URL(address);
    InputStream content = (InputStream)url.getContent();
    Drawable d = Drawable.createFromStream(content , "src"); 
    iv.setImageDrawable(d)

I noticed when I was viewing some of their older comics the image would not show (but 开发者_StackOverflowI was scraping the other information from the page properly so I know the url is correct). I determined that this result only occurs when the image is a .jpg file but works perfectly when it is a .png

I have Googled around plenty and I can't figure out why this is, is there a simple fix for this?


It's a known issue http://code.google.com/p/android/issues/detail?id=6066. Using FlushedInputStream solves it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜