自定义版本更新弹窗

发布时间:2020-08-09 03:32:27 作者:杨充
来源:网络 阅读:201

自定义版本更新弹窗

目录介绍

好消息

该库的GitHub地址:https://github.com/yangchong211/YCUpdateApp

1.本库优势亮点

2.使用介绍

2.1 关于库导入
2.2 使用说明
2.3 lib库中解决了代码中安装 APK文件异常问题【注意lib已经解决该问题】
/**
 * 关于在代码中安装 APK 文件,在 Android N 以后,为了安卓系统为了安全考虑,不能直接访问软件
 * 需要使用 fileProvider 机制来访问、打开 APK 文件。
 * 普通安装
 * @param context                   上下文
 * @param apkPath                   path,文件路径
 * @param pathName                  你的包名
 */
public static void installNormal(Context context, String apkPath , String pathName) {
    if(apkPath==null || pathName==null){
        return;
    }
    Intent intent = new Intent(Intent.ACTION_VIEW);
    File apkFile = new File(apkPath);
    // 由于没有在Activity环境下启动Activity,设置下面的标签
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    //版本在7.0以上是不能直接通过uri访问的
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        //参数1 上下文, 参数2 Provider主机地址 和配置文件中保持一致   参数3  共享的文件
        Uri apkUri = FileProvider.getUriForFile(context, pathName+".fileProvider", apkFile);
        //添加这一句表示对目标应用临时授权该Uri所代表的文件
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
    } else {
        Uri uri = Uri.fromFile(apkFile);
        intent.setDataAndType(uri, "application/vnd.android.package-archive");
    }
    context.startActivity(intent);
}
<provider
    android:name=".VersionFileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>
<?xml version="1.0" encoding="utf-8"?>
<paths>
        <external-path
            name="external_files"
            path="." />
        <root-path
            name="root_path"
            path="." />
</paths>

3.注意要点

4.效果展示

自定义版本更新弹窗
自定义版本更新弹窗
自定义版本更新弹窗
自定义版本更新弹窗
自定义版本更新弹窗
自定义版本更新弹窗

5.其他介绍

关于其他内容介绍

自定义版本更新弹窗

版本更新说明
关于博客汇总链接
关于LICENSE
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://×××w.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
推荐阅读:
  1. grafana版本更新
  2. 微信小程序自定义弹窗实现

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

update 更新弹窗 版本更新

上一篇:南京铭岱网络:INFORGUARD 网页防篡改版本划分

下一篇:Oracle10g/11g动态、静态关闭DRM特性方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》