Android Friend League incremental update

Source: Internet
Author: User
Tags diff

1. Principle of incremental Upgrade
The principle of incremental update is to compare the local apk with the latest version of the server and get the difference package. For example, the current version is 1.1.4, the size is 7.2M, the new version is 1.1.5. The size is 7.3M. We found that there were only 0.1M differences between the two versions, so if we used an incremental upgrade to generate about 0.1M difference packages, users would only need to download the 0.1M diff package for the upgrade without having to re-download the new 7.3M version.

2. Previous incremental upgrade implementations
The first thing to do is to have the service side to generate the diff package, which uses the Bsdiff (binary diff tool) to generate the old and new version of the diff package, and then to download the diff package to the app. The application side is to encapsulate the bspatch into so dynamic library, call the dynamic library via JNI to synthesize the old version of the APK and the diff package into a new version of the APK.

3. Disadvantages of previous incremental upgrades
1. The service side and the client need to implement the function, the time period is long
2. There is no guarantee that users can upgrade to the latest every time, so it is difficult to maintain the difference between each release and the latest version.
3. The client download service side generated by the differential package to be synthesized, there may be a composition failure problem, it is possible that the service side generated the difference package is wrong, there may be a problem with the client composition, the need for a lot of testing and tuning.

4. Friendship League upgrade

4.1 Import the SDK required jar package
Download the latest version of the SDK's Zip package and merge the Libs folder into the local project Libs subdirectory. The libs/armeabi/ file in the Libs directory is a library file that supports the incremental update feature and needs to be added to eclipse.

4.2 Adding a resource file
Copy the Res folder provided by the SDK into the project directory and merge with the project's own res directory. Please do not delete any of the files.

4.3 configuring Androidmanifest.xml
4.3.1 Add the required permissions to the SDK under the tag:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE">< /uses-permission><uses-permission android:name="Android.permission.ACCESS_NETWORK_STATE "></uses-permission><uses-permission android:name="  Android.permission.INTERNET"></uses-permission>

4.3.2 then add appkey and channels to the tag: (If you have integrated the Statistics SDK and other Friends Alliance services, do not need to repeat the addition of Appkey)

 <meta-data android:value= " your APP KEY   " android:name="  umeng_appkey  " /><meta-data Android:value= " channel ID  "  android:name= " umeng_channel  Span style= "COLOR: #800000" "/> 

umeng_appkey: To locate the uniqueness of the app, replace the value with the Umeng APPKEY of your app "YOUR APP KEY".  
umeng_channel: Used to label application promotion channels, different channels can upload different update packages , you can use 20-bit English and numbers for channel naming, replacing "channel ID" in value. If you don't change it, it will represent the default channel, and if you need to automatically update multi-channel updates with friends, you must first integrate the Friends League statistics SDK.  
4.3.3 add service and activity to the label: (Note: In the v2.4 SDK, the dialog box changes to the activity implementation, the Com.umeng package name may change, if it cannot be downloaded, check the package name, replace it with the correct package name)

 <service android:name  = "   "  android:process  = " :D ownloadingservice   " ></service><activity android:name  = " com.umeng.update.updatedialogactivity   "  android:theme  ="   @android: Style/theme.translucent.notitlebar   ></activity> 

4.3.4 Call Update interface
Main application scenario: the most common Automatic update mode, when the user enters the application home page, if in the WiFi environment detects the update, if there is an update, pop-up dialog box prompt to have a new version, the user click the update to start downloading updates.
Called in the OnCreate () method in the Application portal activity

 Public void onCreate (Bundle  savedinstancestate) {    super.oncreate (savedinstancestate);    Umengupdateagent.update (this);

Automatic reminders are now enabled by default in the case of Wi-Fi access. If you need to update automatic reminders in any network environment, add the following code before the update call: Umengupdateagent.setupdateonlywifi (False).

4.4 Uploading the latest apk
If the developer already has the latest APK version, as long as the version number of the client version (Versioncode) is less than the latest version of the upload, the client will have the update prompt when it is launched.

5. Friend League Update Scenario
5.1 Automatic Updates
The most common automatic update mode, when the user enters the application home page, if in the WiFi environment automatically detect the update (the default is only detected in the WiFi environment, is for user traffic considerations. This behavior can be changed), if there is an update, the popup dialog box prompts for a new version, and the user click Update to start downloading the update.
Called in the OnCreate () method in the Application portal activity

 Public void onCreate (Bundle  savedinstancestate) {    super.oncreate (savedinstancestate);    Umengupdateagent.update (this)    //umengupdateagent.update (This, "Appkey" , "channel");

5.2 Manual Update
Main usage Scenarios: Many application settings interface will have to check the update and other similar features, users need to actively trigger the detection of updates. Its default behavior is basically consistent with automatic Updates.
The main difference between this and automatic Updates is that in the case of this manual update, regardless of whether the network condition is WiFi or not, regardless of whether the user has ignored the version of the update, you can initiate an update check in the button's callback, in place of the update (context context), as in the following example:

 Public void OnClick (View v) {    umengupdateagent.forceupdate (mcontext);}

5.3 Silent Download updates
Main use scenario: When the user enters the application homepage after the WiFi environment detects the update, if has the update, the background downloads the new version, if the download succeeds, then carries on the notification bar display, the user clicks the notification bar to begin installs.
Silent download If WiFi disconnects, the download stops.
Called in the OnCreate () method in the Application portal activity

 Public void onCreate (Bundle  savedinstancestate) {    super.oncreate (savedinstancestate);    Umengupdateagent.silentupdate (this);

6. Friend League incremental upgrade
The principle of AU update is: After application integration, the SDK will send the version code and the MD5 value of the APK file to the server side of the app when the app launches. The server finds an older version of the APK with the MD5 value, makes a diff with the old and new apk, generates a patch file, and returns it to the SDK. The SDK then synthesizes the patch file and the old apk file on the phone to generate a new version of the APK. The MD5 value of the new APK file generated by the mobile phone will be consistent with the new APK MD5 value on the server side. In this process, you are required to have a new and old two apk file in the Friend Alliance server.
Au default is the incremental update, if you want to use a full-volume update can call the Setdeltaupdate (Boolean deltaupdate) setting, the default true, set to False is the full-volume update

Android Friend League incremental update

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: 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.