关于版本升级的一点理解(VersionUpdate)
2016-05-24 22:04
363 查看
强调内容
在android中,第一次设计APP的时候不可能面面俱到,需求随时会改变,所以我们就会用到版本升级。
升级:
1.测试tomcat中升级接口
2.编写UpdateEntity
3.编写UpdateParse类
4.编写业务类UpdateBiz
5.发消息、广播处理、下载APK
断点续传:在请求头定义Range:bytes=0-32767
RandomAccessFile:断点下载,断点上传
6.测试APK所在路径是否存在,使用assert(true判断apk路径)
7.安装apk
Intent intent =Intent(Intent.ACTION_VIEW);
intent.setDataAndType(URL.fromFile(new File(APK_PATH)),“application/vnd.android.pakege-archive”); //双引号内表示一个APK文件
startActivity(intent);
8.闪电升级
即提前下载好软件,用户使用的时候直接安装
在android中,第一次设计APP的时候不可能面面俱到,需求随时会改变,所以我们就会用到版本升级。
升级:
1.测试tomcat中升级接口
2.编写UpdateEntity
3.编写UpdateParse类
4.编写业务类UpdateBiz
5.发消息、广播处理、下载APK
断点续传:在请求头定义Range:bytes=0-32767
RandomAccessFile:断点下载,断点上传
6.测试APK所在路径是否存在,使用assert(true判断apk路径)
7.安装apk
Intent intent =Intent(Intent.ACTION_VIEW);
intent.setDataAndType(URL.fromFile(new File(APK_PATH)),“application/vnd.android.pakege-archive”); //双引号内表示一个APK文件
startActivity(intent);
8.闪电升级
即提前下载好软件,用户使用的时候直接安装
public abstract class VersionCheckActivity extends BaseActivity{ /** * 版本更新检测 */ protected void checkVersion(boolean showLoading){ loadDialog = getLoadingDialog("版本更新检测中..."); if(showLoading){ loadDialog.show(); } RequestParam req = new RequestParam(); int vcode = AndroidNativeUtils.getAppVersionCode(getApplicationContext()); req.addStringParam("vcode", String.valueOf(vcode)); gsonRequest = new GsonRequest<ApkVersion>("ApkVersion", ApkVersion.class, req, new Listener<ApkVersion>() { @Override public void onResponse(final ApkVersion response) { // TODO Auto-generated method stub dissmissDialog(); if(!TextUtils.isEmpty(response.downUrl)){ //有更新 showCustomDialogDefault("发现信息版本,请更新",new DialogButtonClickListener() { @Override public void rightButtonClick(Dialog dialog, View view) { // TODO Auto-generated method stub dialog.dismiss(); new ApkDownloader(VersionCheckActivity.this).performDownload(response); } @Override public void leftButtonClick(Dialog dialog, View view) { // TODO Auto-generated method stub dialog.dismiss(); } }); }else{ UIHelper.showShortMeessage("当前版本为最新版本", getApplicationContext()); } } }, new ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub dissmissDialog(); UIHelper.showErrorInfo(error, context); } }); HttpService.getInstance(getApplicationContext()).doPostRequest(gsonRequest); } }
这里写代码片
相关文章推荐
- linux基本命令(33)——df命令
- iOS开发之高级视图—— UITableView(二)编辑选中行
- python读写操作文件
- Reset CSS:只选对的,不选"贵"的
- Deep Learning Hangzhou Meetup--华为2012实验室&深度学习国际群 联合举办
- codeforces #300 A. Cutting Banner
- C++第6次作业
- Git 多人协作开发
- 56.com面试
- 优秀的技术Leader
- 背包问题
- jQery命名空间
- HDU 2089 数位dp水题 统计区间中不包含62 和 4 的个数
- Spark中组件Mllib的学习27之逻辑回归-多元逻辑回归,较大数据集,带预测准确度计算
- 文章标题
- H.265优化问题
- HDU-1116-Play on Words
- 动态规划算法介绍:
- android bluetooth蓝牙移植
- 第二阶段冲刺(五)