Umeng online parameter + automatic update and upgrade SDK implements mandatory update and upgrade for the specified version.
The project has the following requirement: the specified version must be upgraded forcibly, and other versions can be upgraded selectively.
Umeng's automatic update function is still quite useful, but it is not yet in place to force the upgrade.
However, umeng developers have also provided a barely feasible solution:
Umeng online parameters are used to control which versions need to be forcibly updated and which versions do not need to be updated.
The related content is as follows:
1. Online parameter configuration:
Http://dev.umeng.com/analytics/android/advanced-integration-guide#3
2. Force update of official code:
Https://github.com/nxzhou91/umeng-android-sdk-theme/blob/master/blogs/articles/force_update.md
3. My practices:
Configure online parameters, parameter value configuration rules: version number, force update flag, version number, force update flag, version number, force update flag...
Key code:
Private void prepare4UmengUpdate () {MobclickAgent. updateOnlineConfig (MyApplication. getContext (); // obtain the umeng online parameter String update_mode = MobclickAgent. getConfigParams (MyApplication. getContext (), "upgrade_mode"); Log. d (TAG, "MainActivity. prepare4UmengUpdate, update_mode = "+ update_mode); if (StringUtils. isEmpty (update_mode) {return;} // convert to an array mUpdateModeArray = StringUtils. convertStrToArray (update_mode); UmengUpdateAgent. setUpdateOnlyWifi (false); // automatically reminds UmengUpdateAgent to update in any network environment. update (this); // call the umeng update interface String curr_version_name = null; try {curr_version_name = getPackageManager (). getPackageInfo (getPackageName (), 0 ). versionName;} catch (NameNotFoundException e) {// TODO Auto-generated catch block e. printStackTrace () ;}for (int I = 0; I <mUpdateModeArray. length; I + = 2) {if (StringUtils. isEquals (mUpdateModeArray [I], curr_version_name) {if (StringUtils. isEquals (mUpdateModeArray [I + 1], "F") {// click a button in the dialog box to listen to the version to be forcibly updated. If the user does not select an update, disable the app UmengUpdateAgent. setDialogListener (new UmengDialogButtonListener () {@ Override public void onClick (int status) {switch (status) {case UpdateStatus. update: break; default: // automatic Update of umeng. Currently, you have not provided a button to hide/display the Update dialog box in the code, so it is more appropriate to play a Toast here. makeText (MyApplication. getContext (), "Sorry, you need to update the application to continue using", Toast. LENGTH_LONG ). show () ;}}) ;}break; // you only need to find the corresponding version number, that is, the end loop }}}
How to Use umeng's Automatic Updates (android version)
Create a dedicated umeng folder in the project and write the method.
Public static void start (Activity activity ){
// Display the upload Process
// Com. umeng. analytics. MobclickAgent. setDebugMode (true );
// Send an error report
Com. umeng. analytics. MobclickAgent. onError (activity );
// Automatically update
Com. umeng. analytics. MobclickAgent. updateOnlineConfig (activity );
// Talking Initialization
TCAgent. init (activity );
}
Who can tell me where the umeng will automatically update and upload the apk?
Solved by yourself .... Umeng's documentation is really bad, except for the statistical components, the appkey should be configured in the application node. In short, refer to the example in umeng SDK. There should be no dumb in the world.