我的ide是stdio2.3 ,虚拟机版本是7.0, 调用Intent
(MediaStore.ACTION_IMAGE_CAPTURE
),照相时抛出android.os.FileUriExposedException这个异常,根据网官的说法是添加了文件地址暴露的权限,不能使用uri=Uri.fromFile(newFile), 要用FileProvider.getUriForFile(this.getContext(), "
com.mydomain.fileprovider", newFile),具体看官网
点击打开链接,关键在于,按照官网和其它网站的说明都会抛出一个找不到根的异常,原因是
xml目录下按照说明的新建filepaths.xml里面的
<paths>
<files-path path="images/" name="myimages" />
</paths>
需要加上一个root-path ,比如
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<root-path name="camera_photos" path="." />
</paths>
这下相机可以访问储存了,至于什么原因我不知道,反正可以运行了,网上很多文章没有配置root-path,官网也没有,是因为版本的问题?