解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
来源:互联网 发布:php防sql注入代码 编辑:程序博客网 时间:2024/06/07 10:39
http://blog.csdn.net/mr_orange_klj/article/details/69660225
1、在AndroidManifest.xml中添加如下代码
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" ... <application ... <provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/> </provider> </application></manifest>
2、在res目录下新建一个xml文件夹,并且新建一个provider_paths的xml文件
<?xml version="1.0" encoding="utf-8"?><paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="."/></paths>
注意external-path代表了不同的文件目录,一共有五种,下面是官网的说明:
files/
subdirectory of your app's internal storage area. This subdirectory is the same as the value returned byContext.getFilesDir()
.Context.getFilesDir()
.getCacheDir()
.Environment.getExternalStorageDirectory()
.Context#getExternalFilesDir(String) Context.getExternalFilesDir(null)
.Context.getExternalCacheDir()
.3、修改代码
Uri photoURI = Uri.fromFile(createImageFile());
变成:Uri photoURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", createImageFile());
- 顶
- 1
- 踩
阅读全文
0 0
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- (转)解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- Android7.0解决 android.os.FileUriExposedException: file:///storage/emulated/0/
- 解决 Android N 上 安装Apk时报错:android.os.FileUriExposedException: file:///storage/emulated/0/Download/appN
- android.os.FileUriExposedException: file:///storage/emulated/0/myimage/15115
- Android 7.0调用系统相机报错Caused by: android.os.FileUriExposedException: file:///storage/emulated/0/rpms/14
- Android7.0android.os.FileUriExposedException: file:///storage/emulated/0/through Intent.getData()
- android.os.FileUriExposedException:file:///storage/emulated/0/1502852028434.jpg exposed beyond app t
- 开发中碰到的问题:Android 7.0 更新APK在安装时的报错 android.os.FileUriExposedException: file:///storage/emulated/0/And
- android-解决 Android N 上 报错:android.os.FileUriExposedException
- android-解决 Android N 上 报错:android.os.FileUriExposedException
- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException
- 解决 Android N 上 报错:android.os.FileUriExposedException
- 结构化编程和面向对象编程的区别
- 社交网络图挖掘3--重叠社区的发现及Simrank
- u盘文件变成乱码怎么办
- 提升 iOS 开发效率! Xcode 9 内置模拟器的9个技巧
- springMVC的文件配置
- 解决 Android N 上报错:android.os.FileUriExposedException: file:///storage/emulated/0/
- TOP100summit【分享实录-网易】构建云直播分发网络
- C#语言和SQL Server数据库技术_数据库查询基础
- Java并发编程:volatile
- 关于request.get*()
- input弹出的手机键盘搜索事件
- 程序员老鸟写sql语句的经验之谈、百万数据查询优化技巧三十则
- zepto.js
- 小波图像分解与重构