安卓7.0FileUriExposeException跳转相机页面的bug

xiaoxiao2021-02-28  72

1.清单文件

<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>

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> 3、修改代码 Uri photoURI = Uri.fromFile(createImageFile()); 变成: Uri photoURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", createImageFile());

参考:http://www.cnblogs.com/netcorner/p/6542373.html

转载请注明原文地址: https://www.6miu.com/read-57301.html

最新回复(0)