Automatic update of APK using Friends League

Source: Internet
Author: User

"declaration"

Welcome reprint, but please keep the original source of the article →_→

Life One number: http://www.cnblogs.com/smyhvae/

Article Source: http://www.cnblogs.com/smyhvae/p/4653736.html

Contact information: [Email protected]

First, download the SDK:Website Link: http://www.umeng.com/component_update After opening the link, the interface is as follows: In the location shown in the arrows, click on the arrow to download the corresponding version of Android: In the Red box section download the SDK. second, in the Friend Alliance backstage registration application:, click the Red Box section to create a new app. , when the app is created successfully, Appkey is generated, which is what we'll use later. second, in the code to configure:Now start to see what the official documents say, the documentation links are as follows: Http://dev.umeng.com/auto-update/android-doc/quick-start
1. The jar package required to import the SDK:Merge the Libs folder in the SDK into the local project Libs subdirectory. 2. Add a resource file:Copy the Res folder provided by the SDK into the project directory and merge with the project's own res directory.Tips:the resource files provided by the Friends League SDK begin with Umeng_. 3, configuration androidmanifest.xml:3.1. Open Androidmanifest.xml, add the required permissions to the SDK under the <manifest> tab:
1 <uses-permissionAndroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>2 <uses-permissionAndroid:name= "Android.permission.ACCESS_NETWORK_STATE"></uses-permission>3 <uses-permissionAndroid:name= "Android.permission.INTERNET"></uses-permission>

in the above code: the first line of permissions is allowed to save the downloaded apk to the SD card. The second row of permissions allows you to check the status of the network, so that you can determine which download policy to depend on the different network environments and be sure to add that permission.

3.2, immediately after, add Appkey and channel to the <application> tag: (If you have integrated the Statistics SDK and other Friends Alliance services, do not need to add Appkey)
<android:value= "YOUR APP KEY"  android:name= "Umeng_appkey" /> <  android:value= "Channel ID"  android:name= "Umeng_channel"/ >

Umeng_appkey: To locate the uniqueness of the app, replace the "YOUR app KEY" in value with your app's Umeng APPKEY.

Umeng_channel: Used to label the application promotion channel, different channels can upload different update packages, you can use 20-bit English and numbers for channel naming, replace the "channel ID" in value. If you do not change, the default channel will be represented. (Special note: If you need to automatically update multi-channel updates using Friends Alliance, you must first integrate the Friends League statistics SDK) 3.3, add service and activity to the <application> tab:
<ServiceAndroid:name= "Com.umeng.update.net.DownloadingService"android:process= ":D ownloadingservice" ></Service><ActivityAndroid:name= "Com.umeng.update.UpdateDialogActivity"Android:theme= "@android: Style/theme.translucent.notitlebar" ></Activity>

 

4. Call the update interface:Main application Scenarios:    The most common is Automatic UpdatesMode: When the user enters the application home page, if in the WiFi environment detects the update, if there is an update, the pop-up dialog prompts a new version, the user click the update to start downloading the update. The following code is called in the OnCreate () method in the Application portal activity:
1  Public void onCreate (Bundle  savedinstancestate) {2     Super. OnCreate (savedinstancestate ); 3     Umengupdateagent.update (this);

This is the 3rd line of code above the call.

Attention:     Given the limits of user traffic, we are now automatically alerted 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). Special Note: Please also add the above code for devices such as set-top boxes that may not support or do not have a wireless network. 5. Integrated Monitoring:The integration detection feature is turned on by default in the SDK after the v2.4 version, and after you call any of the update interfaces, we will automatically check that the 2 and 32 steps in the integration process have been completed correctly. If there are no prompts to complete correctly, you will be prompted with the following toast. You can disable this feature by calling Umengupdateagent.setupdatecheckconfig (false). Toast has the following meanings:    "Please copy all resources (res/) from the SDK to your project!" : Please check that all the resource files under the Res folder have been placed in the project.    "Add Permission in androidmanifest!" : Check that the relevant permissions for 3.1 in step 1.3 above are added correctly.    "Add Activity in androidmanifest!" : Please check that the activity in step 1.3 above 3.3 is correctly added.    "Add Service in androidmanifest!" : Check that the service in step 1.3 above 3.3 is correctly added.    "Please set Umeng appkey!" : Please check that the Appkey in step 3.2 above is correctly added. third, upload the latest apk to update:Assuming that the previous version number is 1.0, if you have now developed a new version, then as long as the upload to the Friend Alliance website, and the newly developed version number (Versioncode) to be greater than 1.0, the client will start with the update prompt. Let's experiment. , click Components in the Red box section, and then click Auto Update in the Red Box section, and the text hint appears. We especially need to be aware of the text in the Blue box section. We first modify the code in the project file, the text content of TextView to "Oohlala, I am the second version yo". And then Modify the Gradle file in the module of the app to increase the version number。 As shown in:, update the version number of the Red box section. Note that the versioncode of line 11th must be an integer. Then generate a new version of the APK. Then open the Friends League backstage: In, the new version of the APK upload, and fill in the update log. Click "OK" to bring up the following screen: Four, test:v1.0 version of the APK run is the following interface: After adding the Automatic Update function, then open the program, pop up the following interface: In, click "Automatic Update" after the interface is as follows:after the update is finished, the effect is as follows:
Note: If you click the update, the following interface appears: The error is because, the previous two versions of the APK with a different signature caused. In addition, we recommend a link to see: Friends of the Auto Update FAQ index (developer must read) http://bbs.umeng.com/thread-5924-1-1.html "Engineering Document" 2015-07-16-updatedemo Project document

Automatic update of APK using Friends League

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.