App Incremental Update

Source: Internet
Author: User

Concept of incremental update:

When the version of the app installed on our phone is inconsistent with the latest version of the server, the traditional practice is to re-download and install a new version of the APK file, but this is a way of consuming traffic that is not conducive to user experience. An incremental update downloads only the difference between the current app version and the latest version, and then merges the current version with the latest version and then installs it. Currently support incremental update of the application market has GooglePlay, 360 mobile phone market and so on.

How the incremental update works:

Use the Open Source Tool Bsdiff to compare binary files with the new apk and legacy apk, get patch files, and then use the Open Source Tool Bspatch to merge and reinstall the old apk and patch files. In actual development, we only need to write the native method, call. So file to implement the old version of the APK and patch file merge and installation, patch files are generated by the server side.

Code implementation of incremental update: Using Incremental update framework Smartappupdates

  

 //load so library first    Static{system.loadlibrary ("Apkpatchlibrary");    }?  Public voiddownloadnewapk (view view) {//because it is a time-consuming operation, an asynchronous task is required        NewAsynctask<void,void,integer>(){            //3. The new apk file path after compositingString Newapkpath = environment.getexternalstoragedirectory () + "/weibonew.apk"; @OverrideprotectedInteger doinbackground (Void ... params) {//1. Download the patch pack from the server firstFile Patchfile =Downloadpatchfile (); String Patchpath=Patchfile.getabsolutepath (); //2. Get the path to the current version of the APK fileString AppPath = "/data/app/com.sina.weibo-1.apk"; returnPatchutils.patch (Apppath,newapkpath,patchpath);            }? @Overrideprotected voidonpostexecute (Integer integer) {Super. OnPostExecute (integer); if(integer==0){                    //Explain that the composition was successful, then start the installationToast.maketext (mainactivity. This, "synthesized successfully! ", Toast.length_short). Show (); APKUTILS.INSTALLAPK (mainactivity. This, Newapkpath); }Else{toast.maketext (mainactivity). This, "Synthesis failed!", Toast.length_short). Show ();    }}}.execute ();    }? PrivateFile Downloadpatchfile () {return NewFile (Environment.getexternalstoragedirectory (), "Weibo.patch"); }

App Incremental Update

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.