COCOS2DX program under Android platform self-updating policy

Source: Internet
Author: User

COCOS2DX developed a program that runs under the Android platform and is made available to Java layer calls with a. So user library file. So we check for updates in the Java layer, download the latest library file, and skip loading the original library file, loading the new library file.

1. First, add an activity to the Androidmanifest.xml to perform the update.

 <!--  Insert a activity --><activity android:name= "com.guo.UpdateActivity" that performs the download update                    Android:label= "@string/app_name"                    android:screenorientation= "Landscape"                    android:theme= "@android: style/ Theme.NoTitleBar.Fullscreen "                   android:configchanges= "Orientation" >             <intent-filter>                 <action android:name= "Android.intent.action.MAIN"  />      &nbsP;         <category android:name= " Android.intent.category.LAUNCHER " />             </intent-filter>        </activity>

2. The updated process is mainly: version check and download update, load the new. so file.

A. Version check: Add an update configuration file locally when the version is released. Such as:

<?xml version= "1.0" encoding= "Utf-8"?><update><!--whether this feature is open, 1: Yes, other: no--><enable>1</ enable><!--Current Version--><version>1.0.0.1</version> <!--version check url--><versioncheckurl> Http://xxxxxx/update.plist</versioncheckurl></update>

By configuring the check address Http://xxxxxx/update.plist, go to get the latest version number of the server. Update.plist as follows:

<?xml version= "1.0" encoding= "Utf-8"?><update><!--whether this feature is open, 1: Yes, other: no--><enable>1</ enable><!--Server Latest Version--><version>1.0.0.2</version> <!--file: URL + version number + "/" + Cpu_abi + "/" + XXX.S O, this only configures the previous section--><downloadurl>http://192.168.30.124/test/</downloadurl><!--file MD5 value for download checksum <md5>000000000000000000000</md5></update>

B. download the update: If there is an update according to the rules, select the library file download that is appropriate for your CPU architecture. Integrity check after download is complete.

3. Loading. So files

Modify the original Cocos2dxactivity.java file, add skip loading the original library file logic.

Public final static String flag_skip_load_lib = "Key-isskiploadlib";

protected void OnCreate (final Bundle savedinstancestate) {super.oncreate (savedinstancestate); Boolean isskiploadlib = false;if (savedinstancestate! = null) Isskiploadlib = Savedinstancestate.getboolean (FLAG_SKIP_    Load_lib);    if (!isskiploadlib) onloadnativelibraries (); scontext = this;        This.mhandler = new Cocos2dxhandler (this);        Cocos2dxhelper.init (this);    This.init (); if (Mvideohelper = = null) {Mvideohelper = new Cocos2dxvideohelper (this, mframelayout);}}

4. Code too much, directly on the link: source

5. zip compression download and MD5 checksum.

COCOS2DX program under Android platform self-updating policy

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.