|
1
2
3
4
|
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
|
|
1
2
3
4
5
6
7
8
9
|
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.bugly.upgrade.demo.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
|
|
1
2
3
4
5
6
7
|
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<!-- /storage/emulated/0/Download/-->
<external-path name="beta_external_apk" path="Download/"/>
<!--/storage/emulated/0/Android/data/-->
<external-path name="beta_external_apk2" path="Android/data//"/>
</paths>
|
Android 7.0 APK更新适配
本文介绍了解决Android 7.0 (Nougat) 由于StrictMode API政策变化导致的APK更新失败问题。通过使用FileProvider替代直接使用file:// URI的方式,确保了跨应用间文件共享的安全性和兼容性。
998

被折叠的 条评论
为什么被折叠?



