Android解码器->解码为位图下载返回false

标签 android android-layout

我已经开始了

DEBUG/skia(xxxx): --- decoder->decode returned false 

关于我在 ImageViews 中使用的来自 Facebook 的一些个人资料图片的问题。大多数都能完美运行,但偶尔我会发现一个永远无法运行的情况。

出于向后兼容的原因,我正在针对 Android 1.6 编译我的应用程序。

我做了一些挖掘,发现了很多关于这个问题的线索。我已经在使用此处讨论的 FlushedInputStream:http://code.google.com/p/android/issues/detail?id=6066

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

这是一个给我带来麻烦的例子: http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs269.snc3/23132_639284607_390_q.jpg

有人可以检查图像并帮助我找出导致问题的原因吗?

最佳答案

这是一种对我有用的方法:

HttpGet httpRequest = new HttpGet(url);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
                    .execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufferedHttpEntity = new BufferedHttpEntity(entity);
InputStream is = bufferedHttpEntity.getContent();
Drawable d = Drawable.createFromStream(is, "");
//or bitmap
//Bitmap b = BitmapFactory.decodeStream(is);

关于Android解码器->解码为位图下载返回false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16847184/

相关文章:

android - Android 中的网页 View

Android ListView 向下滚动时显示不正确的内容,然后向上滚动时显示正确的内容

android - 如何使用 Facebook Android API v4 检测注销事件?

Android,防止ImageButton拉伸(stretch)TableLayout

android - fragment 之间的启动画面/动画

android - ShareActionProvider在发行版本中缺少共享图标

android - 从右到左语言的滑动标签布局

java - 初学者 Android : Prompt to Leave

android - 无法在文本更改时调整项目组并尊重边距

android-layout - 带页面滑动示例的抽屉导航