电话
400 9058 355
OkHttpUtils是一款封装了okhttp的网络框架,支持大文件上传下载,上传进度回调,下载进度回调,表单上传(多文件和多参数一起上传),链式调用,整合Gson,自动解析返回对象,支持Https和自签名证书,支持cookie自动管理,扩展了统一的上传管理和下载管理功能。
//download the new app
private void downLoadNewApp(NewVersion.XianzaishiRfBean version) {
if (StringUtils.isEmpty(version.getUrl())) {
ToastUtils.showToast("新版本的APP url为空");
enterLoginActivity();
return;
}
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle("正在下载");
dialog.setMessage(version.getDes() + "");
dialog.setCancelable(false);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.show();
if (!NetUtils.hasNet(SplashActivity.this)) {
ToastUtils.showToast("请检查网络环境");
return;
}
System.out.println("SplashActivity.downLoadNewApp=" + version.getUrl());
OkHttpUtils
.get()
.url(version.getUrl())
.build()
.execute(new FileCallBack(Environment.getExternalStorageDirectory().getAbsolutePath(), Conts.NEW_APP_NAME) {
@Override
public void onError(Call call, Exception e, int id) {
enterLoginActivity();
System.out.println("SplashActivity.onError=哈哈哈");
ToastUtils.showToast("下载更新包失败");
}
@Override
public void inProgress(float progress, long total, int id) {
super.inProgress(progress, total, id);
dialog.setProgress((int) (100 * progress));
}
@Override
public void onResponse(File response, int id) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(Uri.fromFile(response),
"application/vnd.android.package-archive");
startActivityForResult(intent, 0);
}
});
}
以上所述是小编给大家介绍的Android okhttputils现在进度显示实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
邮箱:8955556@qq.com
Q Q:8955556
这篇文章主要为大家详细介绍了Android自定义控件实现底部...
这篇文章主要介绍了Android中Toolbar随着Scro...
本文主要介绍了Java图表类库的相关知识。具有很好的参考价值...
本文主要介绍了GIt的基本操作。具有很好的参考价值,下面跟着...
共享内存是在两个正在运行的进程之间共享和传递数据的一种非常有...
这篇文章主要为大家详细介绍了Android自定义相机实现定时...
这篇文章主要介绍了CentOS6.5 上部署 MySQL5....
这篇文章主要介绍了Vue结合原生js实现自定义组件自动生成示...
最近在学习python网络编程这一块,在写简单的socket...
这篇文章主要介绍了微信小程序 数据交互与渲染实例详解的相关资...