前言
我之前在weex的问题合集里面讲过一次这种异常的处理办法不过当时时通过关闭android严苛模式的视角处理的。今天我们来深入sdk,看看这个问题的最佳解决方式
1.我们通过android developer官网搜索android.os.FileUriExposedException这个异常
The exception that is thrown when an application exposes a file:// Uri
to another app.This exposure is discouraged since the receiving app may not have
access to the shared path. For example, the receiving app may not have
requested the Manifest.permission.READ_EXTERNAL_STORAGE runtime
permission, or the platform may be sharing the Uri across user profile
boundaries.Instead, apps should use content:// Uris so the platform can extend
temporary permission for the receiving app to access the resource.This is only thrown for applications targeting Build.VERSION_CODES#N
or higher. Applications targeting earlier SDK versions are allowed to
share file:// Uri, but it’s strongly discouraged.
Android 7.0在文件安全方面提出了更多要求,需要开发者做成额外的配置来明确需求。
2.解决方法
了解FileProvider类的使用
快速解决问题如下:
1.在清单文件里面配置
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.xxx.fileprovider"
android:exported="false"

本文深入探讨了Android中遇到的android.os.FileUriExposedException异常,并提供了通过使用Android的FileProvider类来解决该问题的方法。针对Android 7.0及以上版本的安全要求,建议开发者使用content:// Uri替代file:// Uri,以确保文件访问权限的安全。
最低0.47元/天 解锁文章
android.os.FileUriExposedException最佳解决办法&spm=1001.2101.3001.5002&articleId=107955605&d=1&t=3&u=9bf0497e06474a94a149057c5c612504)
730

被折叠的 条评论
为什么被折叠?



