Skip to content

StrictMode raise android.net.Uri.checkFileUriExposed on ClipData.Item.getUri() #16

Description

@mingchen

OS: Android 6.0

在StrictMode开启后会有如下的错误,而且照片没有保存成功:

E/StrictMode: null
java.lang.Throwable: file:// Uri exposed through ClipData.Item.getUri()
at android.net.Uri.checkFileUriExposed(Uri.java:2346)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:825)
at android.content.Intent.prepareToLeaveProcess(Intent.java:8240)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1508)
at android.app.Activity.startActivityForResult(Activity.java:3930)
at android.app.Activity.startActivityForResult(Activity.java:3890)
at com.jph.takephoto.uitl.TUtils.startActivityForResult(TUtils.java:39)
at com.jph.takephoto.uitl.TUtils.captureBySafely(TUtils.java:69)
at com.jph.takephoto.app.TakePhotoImpl.onPickFromCaptureWithCrop(TakePhotoImpl.java:249)

file:// 因为安全的原因比较新版本的Android系统被废弃了, 解决方案可以参考里的使用 content:// 来替代 file:// https://stackoverflow.com/questions/32623304/when-take-photo-get-java-lang-throwable-file-uri-exposed-through-clipdata

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions