android.os.FileUriExposedException: file:///storage/emulated.. exposed beyond app through Intent.get

安卓7.0遇到 android.os.FileUriExposedException: file:///storage/emulated.. exposed beyond app through Intent.getData()

1、在AndroidManifest.xml中添加如下代码

 



            
        
    

 

2、在res目录下新建一个xml文件夹,并且新建一个provider_paths的xml文件



    

3、修改代码

Uri photoURI = Uri.fromFile(createImageFile());

变成:

Uri photoURI = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", createImageFile());

 

你可能感兴趣的:(Android)