[update] alliance of component Android

Preface

Good and professional services to help developers to save a lot of time. Started as a project also prepare themselves to do their own statistical data, automatic updates, along with the League of friends service time increasing, gradually give up this idea, to study how to more fully, here to share with automatic update component experience.


The statement

Welcome to reprint, but please retain the original source of the article:)

Blog Park:

The farmer uncle:  

The text

A lack of res cannot be upgraded, cause problems

Due to the lack of understanding, official document is of no use to remind, simply copy the SDK jar to the project, don't know what has been upgrading function has been achieved, the key is not wrong! Out again today to test a bit, listen to the UmengUpdateListener interface, found that the client has detected the update, but update dialog pop up, then we noticed the following log:

W/ResourceType(7881): No known package when getting value for resource number 0xffffffff 

Although no display and Umeng have a relationship, or to update the jar, and reverse engineered the jar check code, and check the SDK, was found in a small copy of the resource file, res and drawable, layout, string and things, can be copied into the project! Tucao, ugly -- #, then there is the following:


Two, custom upgrade dialog

/** Version detection */

private void checkVersion() {

UmengUpdateAgent.setUpdateOnlyWifi(true);

UmengUpdateAgent.setUpdateAutoPopup(false);

UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {

@Override

public void onUpdateReturned(int updateStatus,

UpdateResponse updateInfo) {

if (updateStatus == 0 && updateInfo != null) {

showUpdateDialog(updateInfo.path, updateInfo.updateLog);

}

// case 0: // has update

// case 1: // has no update

// case 2: // none wifi

// case 3: // time out

}

});

UmengUpdateAgent.update(this);

}

private void showUpdateDialog(final String downloadUrl, final String message) {

AlertDialog.Builder updateAlertDialog = new AlertDialog.Builder(this);

updateAlertDialog.setIcon(R.drawable.app_icon);

updateAlertDialog.setTitle(R.string.app_name);

updateAlertDialog.setMessage(getString(R.string.update_hint, message));

updateAlertDialog.setNegativeButton(R.string.update_ok,

new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

dialog.dismiss();

try {

startActivity(new Intent(Intent.ACTION_VIEW, Uri

.parse(downloadUrl)));

catch (Exception ex) {

}

}

}).setPositiveButton(R.string.dialog_no, null);

if (!isFinishing())

updateAlertDialog.show();

}


Three, reference

Official document:  


End

Originally did not intend to use the statistical component of Umeng, largely because of the recent blog download the file to the letters (must be logged in), then you will have to find other ways.

Posted by Angelia at November 14, 2013 - 12:47 AM