Android 7.0 安装Apk时报错FileUriExposedException 解决
来源:互联网 发布:漫步者煲机软件 编辑:程序博客网 时间:2024/05/17 04:15
安装Apk时报错FileUriExposedException
1、AndroidManifest.xml写入
<provider android:name="android.support.v4.content.FileProvider" android:authorities="你的包名.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/> </provider>
2、声明res/xml/file_paths
3、file_paths.xml添加内容
<?xml version="1.0" encoding="utf-8"?> <paths> <external-path path="Android/data/你的包名/" name="files_root" /> <external-path path="." name="external_storage_root" /> </paths>
4、启动安装Intent,代码如下
public static void installApk(Context context, String fileName) { Intent intent = new Intent(Intent.ACTION_VIEW); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Uri contentUri = FileProvider.getUriForFile(context, "你的包名.fileprovider", new File(fileName)); intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); } else { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.parse("file://" + fileName), "application/vnd.android.package-archive"); } context.startActivity(intent); }
阅读全文
0 0
- Android 7.0 安装Apk时报错FileUriExposedException 解决
- Android 7.0 安装Apk时报错FileUriExposedException 解决
- 解决 Android N 上 安装Apk时报错:android.os.FileUriExposedException: file:///storage/emulated/0/Download/appN
- 解决Android7.0以上版本升级apk时报android.os.FileUriExposedException的问题
- Android 7.0 FileUriExposedException 解决
- Android 7.0 FileUriExposedException 解决
- Android 7.0 FileUriExposedException 解决
- Android 7.0 FileUriExposedException 解决
- Android 7.0 FileUriExposedException 解决
- (转)Android N安装apk报错:android.os.FileUriExposedException
- Android 7.0 更新APK在安装时的报错 android.os.FileUriExposedException解决办法
- Android 7.0 更新APK在安装时的报错 android.os.FileUriExposedException(已修复)
- 升级安装APK兼容Android7.0,解决FileUriExposedException
- 升级安装APK兼容Android7.0,解决FileUriExposedException
- Android studio 工程安装apk时报错~
- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException
- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException
- 解决 Android N 7.0 上 报错:android.os.FileUriExposedException
- 好用的ReactNative下拉刷新上拉加载的组件,支持iOS和Android
- spring boot + jpa/hibernate配置 failOnEmptyBeans和serializationInclusion
- redis持久化实现原理
- sql优化
- Entity Framework Core 选择数据表的外键
- Android 7.0 安装Apk时报错FileUriExposedException 解决
- JS改变页面颜色
- Unity 工程中含有多个IOSSDK 也就有多个 application openURL 回调
- Python While 循环语句
- Unity5.3 API 之 Microphone(游戏语音SDK )
- Eclipse安装反编译器Decompiler
- java 中substring(int beginIndex, int endIndex) 的用法
- c++精确时间差
- Android runtime机制(二)zygote进程的启动流程