解决exposed beyond app through ClipData.Item.getUri() 错误

解决android N 上 报错解决方法:

FATAL EXCEPTION: main
Process: com.yishu, PID: 5323                                                         android.os.FileUriExposedException: file:///storage/emulated/0/image/1510308272335.jpg exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1816) 
at android.net.Uri.checkFileUriExposed(Uri.java:2350)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:832)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9054)
at android.content.Intent.prepareToLeaveProcess(Intent.java:9039)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1530)
at android.app.Activity.startActivityForResult(Activity.java:4391)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
at android.app.Activity.startActivityForResult(Activity.java:4335)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)

在onCreate中调用如下代码

private void initPhotoError(){
        // android 7.0系统解决拍照的问题
        StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
        StrictMode.setVmPolicy(builder.build());
        builder.detectFileUriExposure();
    }

你可能感兴趣的:(Android点滴)