摘要
版本更新这一块涉及的知识点比较少,但也花了一天时间,仅做记录用,为了方便大家理解,我画了一张流程图。需求比较简单,以后可以根据产品需求适当更改。
以下版本更新工具类
* on 2019/1/23 * 检查更新版本工具类
downLoadPath
url
isforce
oldApkName
newApkName
context
updataDialog
installDialog
progressDialog
fm
updateManager
updateManager
updateManager
updateManager
* 版本更新提示框
updataDialog
v
updataDialog
isforce
v
updataDialog
context
updataDialogfm
* 弹出安装Dialog
content
installDialog content
v
installDialog
isforce
v
installDialog
fileAPK downLoadPath newApkName
context fileAPK
installDialogfm
* 检查有没有最新的APK
file downLoadPath
file
file
fileAPK downLoadPath newApkName
fileAPK
* 删除旧的apk
fileAPK downLoadPath oldApkName
fileAPK
fileAPK
* 下载APK
startTime
startTime
myURL url
conn myURL
conn
is conn
fileSize conn
fileSize
fileSize
is
file1 downLoadPath
file1
file1
fos downLoadPath newApkName
buf
downLoadFileSize
numread isbuf
numread
fosbuf numread
downLoadFileSize numread
downLoadFileSize
fileSize
downLoadFileSizefileSize
progressDialogdownLoadFileSizefileSize
progressDialog
startTime
is
ex
ex ex
* 强制更新时显示在屏幕的进度条
context
progressDialog context
progressDialog
progressDialog
progressDialog
progressDialogSTYLE_HORIZONTAL
progressDialog
* 安装apk
context file
intent ACTION_VIEW
VERSIONSDK_INT
contentUri context file
intentFLAG_ACTIVITY_NEW_TASK
intentFLAG_GRANT_READ_URI_PERMISSION
intentcontentUri
intentFLAG_ACTIVITY_NEW_TASK
intentfile
contextintent
* apk网络地址
context
context context
* apk网络地址
url
url url
* 新版本文件名
fileName
newApkName fileName
* 旧版本文件名
fileName
oldApkName fileName
* Fragment管理器
fm
fm fm
* 下载路径
downLoadPath
downLoadPath downLoadPath
* 是否强制更新
isforce
isforce isforce
下面是发起调用
context fm versionCode url isForced versionCode context
downLoadPath context
newFileName versionCode
oldFileName context
context
fm
downLoadPath
newFileName
oldFileName
url
isForced
其中安装apk需要注意下,在manifest文件中加入代码
provider androidname
androidauthorities
androidgrantUriPermissions
androidexported
metadata
androidname
androidresource
provider
在资源文件中加入
xml version encoding externalpath
name
path
externalpath
name
path
paths
近期发现代码安装APK的时候,在华为手机上不会弹出安装界面
需要在清单文件中配置权限
permission androidname
还没有评论,来说两句吧...