Android(安卓)decoder->decode returned false for Bitmap download
16lz
2021-01-26
推荐安卓开发神器(里面有各种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.
更多相关文章
- Android通过Xutils注解实例化以及事件绑定
- Android使用自定义view在指定时间内匀速画一条直线的实例代码
- ios中getTime()的兼容性实例代码
- android实现气泡聊天
- android Activity的四种启动模式
- Android(安卓)中Activity、Window、ViewRoot、DecorView之间的联
- ListView特效2(列表拖拽)
- [译]Android架构组件 – 查看ViewModel – 第二部分
- Android:LaunchMode使用场景