android7.0后对于file://的限制
错误信息:
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://的限制的更多相关文章
- Android7.0后JNI库必须保留Section Headers
此修改在官网的描述如下: Each ELF file has additional information contained in the section headers. These header ...
- 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 ...
- 拍照、本地图片工具类(兼容至Android7.0)
拍照.本地图片工具类:解决了4.4以上剪裁会提示"找不到文件"和6.0动态授予权限,及7.0报FileUriExposedException异常问题. package com.hb ...
- 【转】Android7.0适配心得
本文出自:贾鹏辉的技术博客(http://www.devio.org) http://www.devio.org/2016/09/28/Android7.0%E9%80%82%E9%85%8D%E5% ...
- Android7.0调用系统相机拍照、读取系统相册照片+CropImageView剪裁照片
Android手机拍照.剪裁,并非那么简单 简书地址:[我的简书–T9的第三个三角] 前言 项目中,基本都有用户自定义头像或自定义背景的功能,实现方法一般都是调用系统相机–拍照,或者系统相册–选择照片 ...
- Android7.0 Doze模式分析(一)Doze介绍 & DeviceIdleController
參考:http://blog.csdn.net/gaugamela/article/details/52981984 在Android M中.Google就引入了Doze模式.它定义了一种全新的 ...
- Android7.0 Phone应用源码分析(二) phone来电流程分析
接上篇博文:Android7.0 Phone应用源码分析(一) phone拨号流程分析 今天我们再来分析下Android7.0 的phone的来电流程 1.1TelephonyFramework 当有 ...
- Android7.0 Phone应用源码分析(一) phone拨号流程分析
1.1 dialer拨号 拨号盘点击拨号DialpadFragment的onClick方法会被调用 public void onClick(View view) { int resId = view. ...
- Android7.0 Phone应用源码分析(三) phone拒接流程分析
本文主要分析Android拒接电话的流程,下面先来看一下拒接电话流程时序图 步骤1:滑动按钮到拒接图标,会调用到AnswerFragment的onDecline方法 com.android.incal ...
随机推荐
- 2019寒假作业三:PTA7-1抓老鼠啊~亏了还是赚了
- 抓老鼠啊~亏了还是赚了? ( 分) 某地老鼠成灾,现悬赏抓老鼠,每抓到一只奖励10元,于是开始跟老鼠斗智斗勇:每天在墙角可选择以下三个操作:放置一个带有一块奶酪的捕鼠夹(T),或者放置一块奶酪(C ...
- Oracle-第一篇一些调优技巧
1.查询 1>通过提示,使用索引. 2>使用/*+parallel*/并行查询 3>查看执行计划,调整sql语句或者优化表结构 4>避免使用“*”号 2.表设计:partiti ...
- C++调用C#类库函数
最近做一个信息化三维仿真项目,基于第三方提供的虚拟引擎通过VC++2008做二次开发,其中涉及到与C#客户端的融合以及数据交互的问题, 主要是VC++需要调用C#客户端提供的类库内的接口获取C#客户端 ...
- 对第一个HelloWorld程序的总结:
/* 注释的作用 :提高了代码的阅读性:调试程序的重要方法 对第一个程序的总结: 创建:创建一个以.java结尾的文件叫做源文件 编译:(javac 源文件名.java) 会生成一个或多个字节码(.c ...
- python学习第四十五天__name__用法和作用
在python导入模块导入另外一个模块的时候,有时候只是想用其一个方法,会出现其他的方法也运行了,python用到__name__==‘__main__’ 解决问题,那么__name__用法和作用 1 ...
- LeetCode102. 二叉树的层次遍历
102. 二叉树的层次遍历 描述 给定一个二叉树,返回其按层次遍历的节点值. (即逐层地,从左到右访问所有节点). 示例 例如,给定二叉树: [3,9,20,null,null,15,7], 3 / ...
- jquery获取年月日时分秒当前时间
获取年月日时分秒的当前时间,可按照某种格式显示出来,下面是一种得到如2017年02月02日 00:00:00格式的当前时间 function getCurrentDate(date){ var y ...
- sqoop简单使用
一,通过sqoop将MySQL里面的数据加载到HDFS 先查看有哪些数据库 查看表person sqoop list-databases --connect jdbc:mysql://ly-p2p4: ...
- 脚本_统计 Linux 进程相关数量信息
#!bin/bash#作者:liusingbon#功能:统计 Linux 进程相关数量信息,running(运行的进程),sleeping(睡眠中的进程),stoped(停止的进程),zombie(僵 ...
- eclipse 代码提示快捷键 alt+/
eclipse (ALT+/)1.选择Eclipse菜单栏中的Window->preferences: 2.选择General->keys; 3.在右侧中间的窗体中点击word compl ...