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 ...
随机推荐
- Vue入门---安装及常用指令介绍
1.安装 BootCDN----官网https://www.bootcdn.cn/ <script src="https://cdn.bootcss.com/vue/2.6.10/vu ...
- linux shell 中的数组的取值 遍历 替换 删除操作
引言 在Linux平台上工作,我们经常需要使用shell来编写一些有用.有意义的脚本程序.有时,会经常使用shell数组.那么,shell中的数组是怎么表现的呢,又是怎么定义的呢?接下来逐一的进行讲解 ...
- Java之九九乘法表
public class MultiplicationTable { public static void main(String[] args) { for(int i=1;i<=9;i++) ...
- [2019杭电多校第七场][hdu6655]Just Repeat
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6655 题意是说两个人都有一些带有颜色的牌,两人轮流出牌,但是不能出对面出过的颜色的牌,最后谁不能出牌谁 ...
- Codeforces 843D (Dijkstra算法的优化,动态最短路)
题面 (http://codeforces.com/problemset/problem/843/D) 题目大意: 给定一张带权无向图,有q次操作 操作有两种 1 v 询问1到v的最短路 2 c 将边 ...
- CSRF verification failed. Request aborted.错误解决办法
在Django项目的页面,提交form表单POST请求时,会出现报错:CSRF verification failed. Request aborted. 需要在form表单中加:{% csrf_to ...
- 洛谷 - P4567 - 文本编辑器 - 无旋Treap
https://www.luogu.org/problem/P4567 事实证明无旋Treap是不是不可能会比Splay快? #include<bits/stdc++.h> using n ...
- SCUT - 274 - CC B-Tree - 树形dp
https://scut.online/p/274 首先要判断是一颗树,并且找出树的直径. 是一棵树,首先边恰好有n-1条,其次要连通,这两个条件已经充分了,当然判环可以加速. 两次dfs找出直径,一 ...
- Gorgeous Sequence(线段树)
Gorgeous Sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- hihocoder1954 : 压缩树
传送门 首先求出缩一个点 $x$ 的贡献,就是缩 $x$ 的父亲的贡献加上 $x$ 的子树多减少的深度 假设此时缩父亲的贡献已经考虑过了,那么 $x$ 的子树多减少的深度就是子树的节点数 注意此时要满 ...