【发布时间】:2018-08-13 20:09:58
【问题描述】:
我正在创建一个聊天应用程序,我在其中从 WhatsApp 等图库中上传图像和视频,但是当我尝试选择已由 WhatsApp 文件夹下载的图像时,我得到了这个路径
/storage/emulated/0/WhatsApp/Media/WhatsAppImages/IMG-20180717-WA0024.jpg
但是当我阅读这篇文章以获得显示图像的真实路径时,我得到了这个异常:
java.io.FileNotFoundException:打开失败:ENOENT(没有这样的文件或目录)
这是我的提供者
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
下面是文件路径
<resources>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="/storage/emulated/0" path="."/>
</paths>
这仅发生在 WhatsApp 媒体上,请告诉我解决方案。
提前致谢
【问题讨论】:
-
你能添加你的java文件代码吗?您是否将提供程序添加到代码中?
-
@LearningAlways 是的,我在清单中添加了这个
-
请用清单文件和一些java代码编辑你的ans。这可能会产生错误。而不是在注释中添加代码。
-
@LearningAlways 已编辑,请立即查看
-
您是否将您的 android:authorities="${applicationId}" 更改为喜欢 android:authorities="com.ex.example.fileprovider"。试试这个以获得更多参考,请参阅下面的答案
标签: android android-contentprovider filepath whatsapp android-storage