`
407827531
  • 浏览: 1082198 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
社区版块
存档分类
最新评论

Android decoder->decode returned false for Bitmap download

    博客分类:
  • Bugs
 
阅读更多

推荐安卓开发神器(里面有各种UI特效和android代码库实例)

There is a bug in FlushedInputStream(is). it fails on slow connections but you can try my magical code to fix it.

Bitmap b =BitmapFactory.decodeStream(newFlushedInputStream(is));
imageView.setImageBitmap(b);

create a static class outside your method

 staticclassFlushedInputStreamextendsFilterInputStream{
        publicFlushedInputStream(InputStream inputStream){
            super(inputStream);
        }

        @Override
        publiclong skip(long n)throwsIOException{
            long totalBytesSkipped =0L;
            while(totalBytesSkipped < n){
                long bytesSkipped =in.skip(n - totalBytesSkipped);
                if(bytesSkipped ==0L){
                    int b = read();
                    if(b <0){
                        break;  // we reached EOF
                    }else{
                        bytesSkipped =1;// we read one byte
                    }
                }
                totalBytesSkipped += bytesSkipped;
            }
            return totalBytesSkipped;
        }
    }

and here you go.. now you will not have any problem.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics