Private String download_url= "http://192.168.2.8:80/downzip/*****.zip";//the Path of the download
Public String Sdpath = Environment.getexternalstoragedirectory (). toString ();
String target = sdpath+ "/downzip/********.zip";//The Save path must include a full file name.
Httputils http = new Httputils ();
HttpHandler handler = Http.download (Download_url,target, True,//If the destination file exists, then the unfinished portion continues to download. The server does not support range when it is newly downloaded.
True,//If the file name is obtained from the request return information, it is automatically renamed after the download is complete.
New Requestcallback<file> () {
@Override
public void OnStart () {
}
@Override
public void onloading (long, long,
Boolean isuploading) {
Update_bt.setvisibility (view.visible);
Update_bt.settext ("Update Progress" + (current * 100/total)
+ "%");
}
@Override
public void onsuccess (responseinfo<file> responseinfo) {
File f = responseinfo.result;
INSTALLAPK (f);
}
@Override
public void OnFailure (httpexception error, String msg) {
LOG.E (TAG, msg);
}
});
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Xutils Tool for download function