错误信息:

04-18 14:56:58.283  4440  4440 W System.err: android.os.FileUriExposedException: file:///storage/emulated/0/temp.jpg exposed beyond app through ClipData.Item.getUri()
04-18 14:56:58.283  4440  4440 W System.err:    at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
04-18 14:56:58.283  4440  4440 W System.err:    at android.net.Uri.checkFileUriExposed(Uri.java:2346)
04-18 14:56:58.283  4440  4440 W System.err:    at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
04-18 14:56:58.283  4440  4440 W System.err:    at android.content.Intent.prepareToLeaveProcess(Intent.java:9044)
04-18 14:56:58.283  4440  4440 W System.err:    at android.content.Intent.prepareToLeaveProcess(Intent.java:9029)
04-18 14:56:58.283  4440  4440 W System.err:    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
04-18 14:56:58.283  4440  4440 W System.err:    at android.app.Activity.startActivityForResult(Activity.java:4341)
04-18 14:56:58.283  4440  4440 W System.err:    at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
04-18 14:56:58.283  4440  4440 W System.err:    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
04-18 14:56:58.283  4440  4440 W System.err:    at android.app.Activity.startActivityForResult(Activity.java:4299)
04-18 14:56:58.283  4440  4440 W System.err:    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
04-18 14:56:58.283  4440  4440 W System.err:    at com.longdai.android.ui.ui2.PersonInfoActivity.b(PersonInfoActivity.java:110)
04-18 14:56:58.283  4440  4440 W System.err:    at com.longdai.android.ui.ui2.PersonInfoActivity$2.onClick(PersonInfoActivity.java:388)
04-18 14:56:58.283  4440  4440 W System.err:    at android.view.View.performClick(View.java:5642)
04-18 14:56:58.283  4440  4440 W System.err:    at android.view.View$PerformClick.run(View.java:22489)
04-18 14:56:58.283  4440  4440 W System.err:    at android.os.Handler.handleCallback(Handler.java:751)
04-18 14:56:58.283  4440  4440 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:95)
04-18 14:56:58.283  4440  4440 W System.err:    at android.os.Looper.loop(Looper.java:154)
04-18 14:56:58.283  4440  4440 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:6217)
04-18 14:56:58.283  4440  4440 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
04-18 14:56:58.283  4440  4440 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1108)
04-18 14:56:58.283  4440  4440 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:998)
04-18 14:56:58.323   548   635 W SurfaceFlinger: eventControl: set enabled=0

官网对于此的限制说明:

https://developer.android.com/reference/android/os/FileUriExposedException.html

The exception that is thrown when an application exposes a file:// Uri to another app.
This exposure is discouraged since the receiving app may not have access to the shared path. For example, the receiving app may not have requested the READ_EXTERNAL_STORAGE runtime permission, or the platform may be sharing the Uri across user profile boundaries.
Instead, apps should use content:// Uris so the platform can extend temporary permission for the receiving app to access the resource.
This is only thrown for applications targeting N or higher. Applications targeting earlier SDK versions are allowed to share file:// Uri, but it's strongly discouraged.

对于代码变化的说明:

在6.0的代码:

/frameworks/base/core/java/android/os/StrictMode.java

1752    /**
1753 * @hide
1754 */
1755 public static void onFileUriExposed(String location) {
1756 final String message = "file:// Uri exposed through " + location;
1757 onVmPolicyViolation(null, new Throwable(message));
1758 }

在7.0的代码:

/frameworks/base/core/java/android/os/StrictMode.java

1793    /**
1794 * @hide
1795 */
1796 public static void onFileUriExposed(Uri uri, String location) {
1797 final String message = uri + " exposed beyond app through " + location;
1798 if ((sVmPolicyMask & PENALTY_DEATH_ON_FILE_URI_EXPOSURE) != 0) {
1799 throw new FileUriExposedException(message);
1800 } else {
1801 onVmPolicyViolation(null, new Throwable(message));
1802 }
1803 }

android7.0后对于file://的限制的更多相关文章

  1. Android7.0后JNI库必须保留Section Headers

    此修改在官网的描述如下: Each ELF file has additional information contained in the section headers. These header ...

  2. android7.0后对于detected problems with app native libraries提示框显示

    log信息: 03-27 09:08:25.887   397   400 W linker  : /data/app/com.guagua.qiqi-1/lib/arm/libMedia.so ha ...

  3. 拍照、本地图片工具类(兼容至Android7.0)

    拍照.本地图片工具类:解决了4.4以上剪裁会提示"找不到文件"和6.0动态授予权限,及7.0报FileUriExposedException异常问题. package com.hb ...

  4. 【转】Android7.0适配心得

    本文出自:贾鹏辉的技术博客(http://www.devio.org) http://www.devio.org/2016/09/28/Android7.0%E9%80%82%E9%85%8D%E5% ...

  5. Android7.0调用系统相机拍照、读取系统相册照片+CropImageView剪裁照片

    Android手机拍照.剪裁,并非那么简单 简书地址:[我的简书–T9的第三个三角] 前言 项目中,基本都有用户自定义头像或自定义背景的功能,实现方法一般都是调用系统相机–拍照,或者系统相册–选择照片 ...

  6. Android7.0 Doze模式分析(一)Doze介绍 & DeviceIdleController

     參考:http://blog.csdn.net/gaugamela/article/details/52981984 在Android M中.Google就引入了Doze模式.它定义了一种全新的 ...

  7. Android7.0 Phone应用源码分析(二) phone来电流程分析

    接上篇博文:Android7.0 Phone应用源码分析(一) phone拨号流程分析 今天我们再来分析下Android7.0 的phone的来电流程 1.1TelephonyFramework 当有 ...

  8. Android7.0 Phone应用源码分析(一) phone拨号流程分析

    1.1 dialer拨号 拨号盘点击拨号DialpadFragment的onClick方法会被调用 public void onClick(View view) { int resId = view. ...

  9. Android7.0 Phone应用源码分析(三) phone拒接流程分析

    本文主要分析Android拒接电话的流程,下面先来看一下拒接电话流程时序图 步骤1:滑动按钮到拒接图标,会调用到AnswerFragment的onDecline方法 com.android.incal ...

随机推荐

  1. <每日一题> Day1:CodeForces.1140D.MinimumTriangulation(思维题)

    题目链接 参考代码: #include <iostream> using namespace std; int main() { ; int n; cin >> n; ; i ...

  2. js 判断是不是数字||判断字符串是不是数字(正则表达式)

    js使用正则表达式判断对象是不是数字,或者字符串是不是数字,或者是不是数字类型 //判断是不是一个数字 或者 一个字符串里全是数字 isNumber (value) { if (value === u ...

  3. WinForm:如何在ListBox中添加CheckBox

    http://www.cnblogs.com/myshell/archive/2010/09/24/1834184.html 最近因为做WinForm的项目,遇到这个问题,当时以为CheckedLis ...

  4. 攻防世界--ReverseMe-120

    测试文件:https://adworld.xctf.org.cn/media/task/attachments/a5c0e8322d9645468befabddfe0cb51d.exe 1.准备 获取 ...

  5. spark浅谈(1):RDD

    一.弹性分布式数据集 1.弹性分布式数据集(RDD)是spark数据结构的基础.它是一个不可变的分布式对象的集合,RDD中的每个数据集都被划分为一个个逻辑分区,每个分区可以在集群上的不同节点上进行计算 ...

  6. basename函数不能获取url路径中文文件名的问题

    basename basename() 函数返回路径中的文件名部分. 语法 basename(path,suffix) 参数 描述 path 必需.规定要检查的路径. suffix 可选.规定文件扩展 ...

  7. Nginx优化_自定义报错页面

    自定义返回给客户端的404错误页面 1. 优化前,客户端使用浏览器访问不存在的页面,会提示404文件未找到 client]# firefox http://192.168.4.5/xxxxx      ...

  8. APKMirror - 直接下载google play里的应用

    APKMirror - Free APK Downloads - Download Free Android APKs #APKPLZ https://www.apkmirror.com/

  9. uiautomatorviewer不能直接截取手机屏幕信息

    本身可以用sdk——>tools里自带的ui automator viewer截取如果截取不了,采用以下方法: 新建一个文本文档,名字自己起如uni.bat(注意把后缀给改成.bat) adb ...

  10. #10042. 「一本通 2.1 练习 8」收集雪花 || 离散化 || 双指针法 || C++ || LOJ

    题目:#10042. 「一本通 2.1 练习 8」收集雪花 看到网上没有这道题的题解,所以写一下. 要标记数字是否存在,看到x<=1e9,所以考虑用离散化,然后开一个last数组,last[i] ...