求助~~~安卓自动更新问题

安卓开发中UMeng的自动更新的SDK不能用了,现在大家都是用什么SDK做自动更新?

前言

又好又专业的服务能帮开发者省很多时间。一开始做项目也准备自己来统计数据、自己做自动更新,随着使用友盟服务的时间增加,渐渐放弃了这种想法,转而研究如何更充分的使用,这里分享一下使用自动更新组件的心得。

声明
欢迎转载,但请保留文章原始出处:)
博客园:http://www.cnblogs.com
农民伯伯: http://over140.cnblogs.com

正文

一、缺少res导致不能升级的问题

    由于缺少了解,官网文档也没用提醒,仅仅拷贝了SDK的jar到工程里,一直不知道到底升级功能是否已经实现,关键是也不报错!今天又拿出来测试了一下,监听了一下UmengUpdateListener接口,发现客户端已经检测到了更新,但是没用弹出更新的对话框,然后就注意到了如下log:

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

    虽然没用显示和umeng有关系,还是重新更新了一下jar,并且反编译了一下jar查看了一下代码,并检查了一下sdk,果然发现少拷贝了资源文件,res下还有drawable、layout、string还有东西,拷贝进项目即可!吐槽一下,好丑 - - # ,然后就有了下面:



二、自定义升级对话框

复制代码
/** 版本检测 */
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();
}

复制代码

三、参考

    官网文档:http://dev.umeng.com/doc/document_update_android.html