android - 无法在 M 预览中从外部存储加载图像

标签 android picasso android-ion android-6.0-marshmallow

我有一个将图像存储在外部存储器上的应用程序。在我尝试新的 M 预览版之前,它一直运行良好。

我使用 picasso(我什至尝试过 Ion)加载图像,并使用“file:///mnt/sdcard/appname/image1.jpg”URI 获取图像。

我没有收到任何错误,但我猜测 M 已经更改了从外部存储读取的权限。我试过谷歌搜索,但一无所获。

顺便说一句,将图像写入外部存储的工作正常。

最佳答案

尽管 siris_cac 的回答得到了很好的解释,但这并不是导致我出现问题的原因。 结果我无法使用“file:///mnt/sdcard/appname/image1.jpg”从 M 中的外部存储加载文件。

我想这可能与 http://www.androidpolice.com/2015/05/28/android-m-feature-spotlight-external-storage-can-be-adopted-as-true-internal-storage-or-accessed-normally-with-no-additional-apps/ 有关

我想我从一开始就错了,没有在加载图像时仅在保存图像时使用 Enviroment.getExternalStorageDirectory()。

现在加载我使用的图像:

"file:///" + Environment.getExternalStorageDirectory().getPath() + "/appname/image1.jpg";

关于android - 无法在 M 预览中从外部存储加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30568124/

相关文章:

android - 如何从 Activity 返回到上一个 fragment ?

android - 在android中使用陀螺仪获取角度

android - 图像不加载在 android 5.0 使用 picasso 库

android - 如何在 Android 上满足 Apache POI 的依赖性?

java - 无法创建和复制文件

android - Retrofit response : Cache Control. 是什么意思?

android - 带有从 URL 下载的位图的 ImageView(重复平铺模式)

Android koush/ion lib 无法发布和接收 JSON 响应

android - 使用 ion 将图像加载到 android imageView 中会返回模糊的结果

android - 使用 Ion 环绕 ImageView