Android的德codeR->德code返回false的位图下载 [英] Android decoder->decode returned false for Bitmap download
问题描述
我已经开始得到一个
DEBUG/skia(xxxx): --- decoder->decode returned false
问题上从Facebook,我在ImageViews使用一些个人资料图片。大多数工作完美,但每过一段时间我发现一个从来没有工作。
issue on a few profile images from Facebook that I use in ImageViews. Most work perfectly, but every once in a while I discover one that never works.
我编译我对Android 1.6的应用程序向后兼容的原因。
I am compiling my application against Android 1.6 for backward compatibility reasons.
我做了一些挖掘,发现了一些关于这个问题的线程。我已经使用了FlushedInputStream这里讨论:<一href="http://$c$c.google.com/p/android/issues/detail?id=6066">http://$c$c.google.com/p/android/issues/detail?id=6066
I did some digging and discovered a number of threads on the issue. I'm already using the FlushedInputStream discussed here: http://code.google.com/p/android/issues/detail?id=6066
Bitmap b = BitmapFactory.decodeStream(new FlushedInputStream(is));
imageView.setImageBitmap(b);
下面是这是造成我的麻烦的例子: <一href="http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs269.snc3/23132_639284607_390_q.jpg">http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs269.snc3/23132_639284607_390_q.jpg
Here's an example that's causing me trouble: http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs269.snc3/23132_639284607_390_q.jpg
有人可以检查出的形象,帮我找出是什么导致了麻烦?
Can someone check out the image and help me figure out what's causing the trouble?
推荐答案
有一个在FlushedInputStream(是)一个错误。它失败的连接速度慢,但你可以试试我的神奇code,以解决它。
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(new FlushedInputStream(is));
imageView.setImageBitmap(b);
你的方法之外创建一个静态类
create a static class outside your method
static class FlushedInputStream extends FilterInputStream {
public FlushedInputStream(InputStream inputStream) {
super(inputStream);
}
@Override
public long skip(long n) throws IOException {
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的德codeR-&GT;德code返回false的位图下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!