毕加索没有显示在某些三星设备从画廊图像 [英] Picasso not showing Images from gallery on certain Samsung devices

查看:208
本文介绍了毕加索没有显示在某些三星设备从画廊图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些(所有?)三星设备(银河S5,S3)毕加索不显示图像,从画廊。

On some (all?) Samsung devices (Galaxy S5, S3) Picasso does not display Images from the Gallery.

这是code:

File[] picFiles = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).listFiles();

File file = picFile[0]; 

我试过:

Picasso.with(getActivity()).load(Uri.fromFile(file)).into(imageView);

以及

Picasso.with(getActivity()).load("file://" + file.getAbsolutePath()).into(imageView);

无济于事。在所有非三星设备boths片段精细工作:

to no avail. On all non-samsung devices boths snippets work fine:

该文件的路径没有来自其他设备的外观不同,例如:

The path to the files do not look different from other devices, example:

/storage/emulated/0/Pictures/JPEG_20150706_112313_826588781.jpg

还有什么比这里是什么问题?

What could be the problem here?

编辑:是的,我已经添加了 android.permission.READ_EXTERNAL_STORAG​​E 。该文件存在,并且图像在Gallery应用程序可见。

Yes I have added android.permission.READ_EXTERNAL_STORAGE. The file exists and the Image is visible in the gallery app.

编辑2:这是毕加索的stracktrace:

EDIT 2: This is the stracktrace from Picasso:

07-13 07:22:22.817  14648-14921/xy I/dalvikvm﹕ "Picasso-/storage/emulated/0/Pictures/JPEG_20150713_071858_-1853613631.jpg" prio=5 tid=51 RUNNABLE
07-13 07:22:22.817  14648-14921/xy I/dalvikvm﹕ at com.squareup.picasso.BitmapHunter.decodeStream(BitmapHunter.java:142)
07-13 07:22:22.817  14648-14921/xy I/dalvikvm﹕ at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:217)
07-13 07:22:22.817  14648-14921/xy I/dalvikvm﹕ at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
07-13 07:22:22.817  14648-14921/xy I/dalvikvm﹕ at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)
07-13 07:22:23.167  14648-14918/xy﹕ "Picasso-/storage/emulated/0/Pictures/JPEG_20150713_071858_-1853613631.jpg" prio=5 tid=49 RUNNABLE
07-13 07:22:23.167  14648-14918/xy﹕ at com.squareup.picasso.BitmapHunter.transformResult(BitmapHunter.java:558)
07-13 07:22:23.167  14648-14918/xy﹕ at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:232)
07-13 07:22:23.167  14648-14918/xy﹕ at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
07-13 07:22:23.167  14648-14918/xy﹕ at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)

它并不真正似乎揭示不被显示的图像的原因。

It doesn't really seem to reveal the reason for the image not being displayed.

毕加索的版本是2.5.2,我可以重现错误的三星S3搭载Android 4.4.4和三星S5采用Android 5.0。

Picasso version is 2.5.2, I could reproduce the error on a Samsung S3 with Android 4.4.4 and a Samsung S5 with Android 5.0.

UIL 是同一图像加载就好了,所以它可能是一个错误在毕加索,我可能会在文件的github上的bug报告。

UIL is loading the same image just fine, so it's probably a bug in Picasso, I'll probably file a bug report at their github.

最后编辑时间:这个问题实际上是逃避我的注意,因为我过滤我的LogCat中的错误的关键词的OOM异常。我现在非常惭愧。

LAST The problem actually was an OOM exception that eluded my attention because I filtered my LogCat for the wrong keywords. I'm quite ashamed of myself now.

picasso.load().fit().into() 

工作和正在显示的图像。感谢你的帮助。

works and the image is being displayed. Thanks for your help.

推荐答案

您最有可能加载非常大的图像可导致的OutOfMemoryError 。您可以调整位图并保持纵横比。

You are most likely loading very large images which can lead to an OutOfMemoryError. You can resize the Bitmap and keep the aspect ratio.

得到一个位图的宽度和高度没有加载到存储器的示例:

Example of getting the width and height of a bitmap without loading it into memory:

File file = new File("/path/to/some/picture.jpg");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
int width = options.outWidth;
int height = options.outHeight;

告诉毕加索调整图像大小,以避免的OutOfMemoryError

if (width > MAX_WIDTH || height > MAX_HEIGHT) {
    Picasso.with(context).load(uri)
        .resize(MAX_WIDTH, MAX_HEIGHT)
        .centerInside()
        .into(yourImageView);
}

这篇关于毕加索没有显示在某些三星设备从画廊图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆