0
点赞
收藏
分享

微信扫一扫

exposed beyond app through Intent.getData() 下载APK后安装APK

清冷的蓝天天 2022-09-21 阅读 45


exposed beyond app through Intent.getData() 下载APK后安装APK_ide


<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.administrator.myapplication.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>


 

exposed beyond app through Intent.getData() 下载APK后安装APK_xml_02

 

exposed beyond app through Intent.getData() 下载APK后安装APK_ide_03


<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="office" path="."/>
</paths>


exposed beyond app through Intent.getData() 下载APK后安装APK_android_04


//判断是否是AndroidN以及更高的版本
Intent intent = new Intent(Intent.ACTION_VIEW);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Uri contentUri = FileProvider.getUriForFile(mContext, "com.example.administrator.myapplication.fileprovider", file);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
} else {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
}
mContext.startActivity(intent);
}


 

 

举报

相关推荐

0 条评论