安卓开发拍照时闪退遇到问题: file:///storage/emulated/0/0.jpg exposed beyond app through ClipData.Item.getUri()

问题描述:

打开摄像头拍照时程序闪退,错误提示如下:

android.os.FileUriExposedException: file:///storage/emulated/0/RadioDirectory/IMG_20190417_095708.jpg exposed beyond app through ClipData.Item.getUri()

截图:

安卓开发拍照时闪退遇到问题: file:///storage/emulated/0/0.jpg exposed beyond app through ClipData.Item.getUri()_第1张图片

解决方法:

在Application的onCreat()方法中添加以下代码:

StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();

 

你可能感兴趣的:(遇到的问题及解决方法)