Android 内部更新实践 完美解决各个版本

3. 安装新版本的APP

1. 创建工具类文件 InstallUtil.java

文件内容链接 https://blog.csdn.net/bencheng06/article/details/82887948

2. 注册应用安装FileProvider

  <!-- 注册应用安装FileProvider -->
        <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>

3. 注册安装权限,忘记注册会报错

<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

Android APP更新实践 - 完美解决9.0前的各种版本.md

4. 在使用的地方调用一下

 new InstallUtil((Activity) context, appPath).install();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-07-27
  • 2021-09-01
  • 2021-12-05
  • 2021-11-11
  • 2021-09-08
猜你喜欢
  • 2021-08-09
  • 2021-12-26
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案