Android 7.0 Provider使用
16lz
2021-01-23
举个栗子:版本更新
版本安装:
/** * 安装Apk * * @param context * @param apkPath */public static void installApk(Context context, String apkPath) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Uri uri = FileProvider.getUriForFile(context, "com.common.diffapp.provider", new File(apkPath)); Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(uri, "application/vnd.android.package-archive"); context.startActivity(intent); } else { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + apkPath), "application/vnd.android.package-archive"); context.startActivity(intent); }}
配置AndroidManifest.xml
配置file_paths:
<?xml version="1.0" encoding="utf-8"?>//这路径不推荐使用,我测试随便用的
一些配置xml的属性:
<?xml version="1.0" encoding="utf-8"?>
这些配置路径说白了就是和你存储的file文件有关系;
扩展:https://blog.csdn.net/leilifengxingmw/article/details/57405908
报错的情况要多检查下xml配置的file路径:IllegalArgumentException: Failed to find configured root that contains
更多相关文章
- Android GLSurfaceView在屏幕旋转后绘图区域异常的解决办法
- android 华为Mate 10 spinner 点击区域bug
- Android监听Dialog点击外部区域
- Android 在TextView中加入多个点击文本区域
- android 获取外置sd卡根目录
- Android 点击空白区域 软键盘消失
- Android——扩大ImageButton的点击区域
- android点击空白区域隐藏软键盘的实现
- android朋友圈监听键盘状态 点击空白区域隐藏键盘