【问题标题】:Why Uri.fromFile() will not work on Android 7.0+, with a targetSdkVersion of 24 or higher. and what can be the alternate solution ? (Kotlin)为什么 Uri.fromFile() 不适用于 Android 7.0+,targetSdkVersion 为 24 或更高。什么是替代解决方案? (科特林)
【发布时间】:2020-06-15 12:16:09
【问题描述】:

android.os.FileUriExposedException: file:///null 通过 ClipData.Item.getUri() 暴露在应用之外

这是显示给我的错误。什么是合适的选择?

【问题讨论】:

    标签: android kotlin file-io uri


    【解决方案1】:

    --->这可以是另一种选择

    变化:

    返回 Uri.fromFile(mediaFile);

    成为:

    return FileProvider.getUriForFile(getApplicationContext(), getPackageName()+".fileprovider", mediaFile);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-13
      • 2017-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-02
      • 1970-01-01
      • 2018-04-26
      相关资源
      最近更新 更多