Okhttputils is a package of okhttp network framework, supporting large file upload download, upload progress callback, download progress callback, form upload (multiple files and multiple parameters upload), chain call, integration Gson, automatically resolve return object, support HTTPS and self-signed certificate, Support Cookie automatic management, extended unified upload management and download management functions.
Download the new app private void Downloadnewapp (Newversion.xianzaishirfbean version) {if Stringutils.isempty (
Version.geturl ()) {Toastutils.showtoast ("New version of App URL is empty");
Enterloginactivity ();
Return
Final ProgressDialog Dialog = new ProgressDialog (this);
Dialog.settitle ("Downloading");
Dialog.setmessage (Version.getdes () + "");
Dialog.setcancelable (FALSE);
Dialog.setprogressstyle (progressdialog.style_horizontal);
Dialog.show (); if (!
Netutils.hasnet (Splashactivity.this)) {toastutils.showtoast ("Please check the network environment");
Return
} System.out.println ("splashactivity.downloadnewapp=" + Version.geturl ()); Okhttputils. Get (). URLs (Version.geturl ()). Build (). Execute (New Filecallback ENVIRONMENT.G Etexternalstoragedirectory (). GetAbsolutePath (), conts.new_app_name) {@Override public void OnError (Ca
ll call, Exception e, int id) {enterloginactivity (); SystEm.out.println ("splashactivity.onerror= hahaha");
Toastutils.showtoast ("Download update package failed"); @Override public void inprogress (float progress, long total, int id) {super.inprogress (
Progress, total, id);
Dialog.setprogress ((int) (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);
}
}); }
The above is a small set to introduce the Android Okhttputils now progress show instance code, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!