安卓系统下的多线程断点下载实现2利用开源框架XUtils

使用开源框架可以大大降低开发的难度,减少开发的周期,并且bug也少的多,,软件运行起来更稳定。

xUtils简介

xUtils 包含了很多实用的android工具。 xUtils 支持大文件上传,更全面的http请求协议支持(10种谓词),拥有更加灵活的ORM,更多的事件注解支持且不受混淆影响… xUitls 最低兼容android 2.2 (api level 8)

下载地址:https://github.com/wyouflf/xUtils

下面是一个demo:

{private EditText et_path;private TextView tv_info;(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);et_path = (EditText) findViewById(R.id.et_path);tv_info = (TextView) findViewById(R.id.tv_info);}(View view){String path = et_path.getText().toString().trim();if(TextUtils.isEmpty(path)){Toast.makeText(this, “请输入下载的路径”, 0).show();return;}else{HttpUtils http = new HttpUtils();HttpHandler handler = http.download(path,”/sdcard/xxx.zip”,RequestCallBack<File>() {() {tv_info.setText(“conn…”);}(long total, long current, boolean isUploading) {tv_info.setText(current + “/” + total);}(ResponseInfo<File> responseInfo) {tv_info.setText(“downloaded:” + responseInfo.result.getPath());}(HttpException error, String msg) {tv_info.setText(msg);}});}}}

利用现成的开源框架,实现起来好处多多!

赚钱之道很多,但是找不到赚钱的种子,便成不了事业家。

安卓系统下的多线程断点下载实现2利用开源框架XUtils

相关文章:

你感兴趣的文章:

标签云: