前言
我之前在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"</