028-86922220

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

自定义版本更新弹窗

自定义版本更新弹窗

目录介绍

好消息

该库的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);
}

    


        
        

3.注意要点

4.效果展示

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

创新互联是一家以网站建设公司、网页设计、品牌设计、软件运维、成都网站营销、小程序App开发等移动开发为一体互联网公司。已累计为成都铜雕雕塑等众行业中小客户提供优质的互联网建站和软件开发服务。

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.

名称栏目:自定义版本更新弹窗
转载注明:http://www.tsicrk.com/article/gohjce.html

其他资讯

让你的专属顾问为你服务

2.2398s