Android Okhttputils now progress to display instance code _android

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.