Software update related, using Utuils framework online upgrade, display ProgressDialog, download finished automatically eject the installation interface.

Source: Internet
Author: User

Use utuils frame to upgrade online, display ProgressDialog, automatically eject the installation screen after downloading.

1     Private voidupdatedownload () {2         //detect if a memory device is available3         if(Environment.getexternalstoragestate (). Equals (environment.media_mounted)) {4             //Set Storage Path5             FinalString Targer = environment.getexternalstoragedirectory () + "/update.apk";6LOG.E ("Test", "Storage path:" +Targer);7Httputils Utils =Newhttputils ();8LOG.E ("Test", "Create Httputils");9 TenUtils.download (Mdownloadurl, Targer,NewRequestcallback<file>() { One                 //Set ProgressDialog AProgressDialog ProgressDialog =NewProgressDialog (splashactivity. This); -                 //Update download Progress - @Override the                  Public voidOnloading (LongTotalLongCurrentBooleanisuploading) { -                     Super. onloading (Total, Current, isuploading); -LOGUTILS.E ("Progress:" +Current ); -Progressdialog.settitle ("Downloading:"); +  -                     //set current download progress as a percentage +                     intBar = (int) (Current*100/Total ); AProgressdialog.setmessage ("Current Download:" + Bar + "%"); at                     //show the progress. - progressdialog.show (); -                 } -  -                 //Success - @Override in                  Public voidOnsuccess (responseinfo<file>responseinfo) { -LOG.E ("Test", "Download succeeded"); to                     //Open the installation package +Intent Intent =NewIntent (intent.action_view); - intent.addcategory (intent.category_default); the Intent.setdataandtype (Uri.fromfile (responseinfo.result), *"Application/vnd.android.package-archive"); $                     //startactivity (intent);Panax Notoginseng                     //If the user cancels the installation, the result is returned, and the callback method Onactivityresult -Startactivityforresult (Intent, 0); the                 } +  A                 //failed the @Override +                  Public voidonfailure (HttpException E, String s) { -Toast.maketext (splashactivity. This, "Download Failed", toast.length_short); $ enterhome (); $                 } -  -             }); the}Else { -             //No memory cardWuyiToast.maketext (splashactivity. This, "No storage device detected", toast.length_short); the enterhome (); -         } Wu  -     } About  $     //when the user cancels the installation of the software - @Override -     protected voidOnactivityresult (intRequestcode,intResultCode, Intent data) { -         Super. Onactivityresult (Requestcode, ResultCode, data); A enterhome (); +}

Software update related, using Utuils framework online upgrade, display ProgressDialog, download finished automatically eject the installation interface.

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.