错误信息:

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. 在使用spring中的ContextConfiguration、test注解时出现的错误

    错误: 在使用测试注解时出现ContextConfiguration注解和test注解无法正常导包使用的编译异常,如图: 解决办法: 将pom.xml文件中以下依赖管理 中的<scope> ...

  2. xml与Properties的区别

    1.properties配置文件,是一个属性对应于一个值(key = value)这样的键值匹对模式: 每一行properties配置文件的键值,对应着一次赋值: 特殊点: 在前后两行properti ...

  3. appscan 9.0.3.12 版本下载--补丁验证---win10 验证OK

    链接:扫描下面二维码

  4. svn登录问题

    转载自: https://www.cnblogs.com/WQX-work24/p/9790260.html 版权归该作者所有.

  5. spark复习笔记(5):API分析

    0.spark是基于hadoop的mr模型,扩展了MR,高效实用MR模型,内存型集群计算,提高了app处理速度. 1.特点:(1)在内存中存储中间结果 (2)支持多种语言:java scala pyt ...

  6. linux基础开发软件安装 - java相关

    1.linux在线安装mysql:转自 https://www.cnblogs.com/bigbrotherer/p/7241845.html ,写的很好,简单易用. 开启远程访问:转 https:/ ...

  7. iOS 应用配置及证书生成教程

    简介 首先你需要有一个苹果的开发者帐号,一台苹果电脑.点击查看苹果开发者账号注册流程 本教程需完成应用信息配置,包括如下两个基本配置: AppID Bundle ID 同时,生成 如下三个证书文件及对 ...

  8. C++宽字符串转字符串

    这文章是更改别人代码 #include <string> #include <iostream> #include <stdlib.h> #include < ...

  9. hr员工数据分析(实战)

    hr员工数据分析项目实战 (数据已脱敏) 背景说明 某公司最近公司发生多起重要员工意外离职.部分员工工作缺乏积极性等问题,受hr部门委托,开展数据分析工作. 经与hr部门沟通,确定以下需求: 制定数据 ...

  10. 【python】pyenv与virtualenv安装,实现python多版本多项目管理

    踩了很多坑,记录一下这次试验,本次测试环境:Linux centos7 64位. pyenv是一个python版本管理工具,它能够进行全局的python版本切换,也可以为单个项目提供对应的python ...