android 版本 升级,Android版本更新实例详解

Android版本更新实例详解

1、导入xutils的jar包

0dfd2bf0b5520fd571d2e72268c2104f.png

2、在AndroidManifest.xml中添加权限

3、选择下载的路径,和下载apk文件的网址

private String url=”http://www.oschina.NET/uploads/osc-Android-v2.6.4-release.apk”;

private String sdPath = “/sdcard/” + System.currentTimeMillis() + “yuyin.apk”;

4、当点击按钮的时候进行下载

HttpUtils httpUtils=new HttpUtils();

//参数一:下载的路径 参数二:下载到sdpath的路径 参数三:

httpUtils.download(url, sdPath, true, new RequestCallBack() {

@Override

public void onSuccess(ResponseInfo arg0) {

mBtn.setText("下载完成");

//路径

String path = arg0.result.getPath();

File file = new File(path);

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");

startActivity(intent);

}

@Override

public void onFailure(HttpException arg0, String arg1) {

mBtn.setText("下载失败");

}

@Override

public void onLoading(long total, long current, boolean isUploading) {

// TODO Auto-generated method stub

super.onLoading(total, current, isUploading);

mBtn.setText("正在下载.....");

}

@Override

public void onStart() {

super.onStart();

mBtn.setText("开始下载");

}

});

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值