Java Code Examples for com.umeng.update.UmengUpdateAgent#setUpdateListener()

The following examples show how to use com.umeng.update.UmengUpdateAgent#setUpdateListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
public void checkUpdate() {
	UmengUpdateAgent.setUpdateAutoPopup(false);
	UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
		
		@Override
		 public void onUpdateReturned(int updateStatus,UpdateResponse updateInfo) {
	        switch (updateStatus) {
	        case UpdateStatus.Yes: // has update
	            UmengUpdateAgent.showUpdateDialog(MainActivity.this, updateInfo);
	            break;
	        case UpdateStatus.No: // has no update
	        	showMsg("当前已是最新版本"+SF.TIP);
	            break;
	        case UpdateStatus.Timeout: // time out
	        	showMsg("检测超时"+SF.FAIL);
	            break;
	        }
	        UmengUpdateAgent.setUpdateAutoPopup(true);
			UmengUpdateAgent.setUpdateListener(null);
	    }
	});
	showMsg("检测更新中,请稍候...");
	UmengUpdateAgent.update(this);
}
 
Example 2
Source File: UserCenterActivity.java    From QiQuYing with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	ViewUtils.inject(this);
	init();
	initCheckBoxStatusAndSetListenner();
	UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
	    @Override
	    public void onUpdateReturned(int updateStatus,UpdateResponse updateInfo) {
	        switch (updateStatus) {
	        case UpdateStatus.Yes: // has update
	            UmengUpdateAgent.showUpdateDialog(UserCenterActivity.this, updateInfo);
	            break;
	        case UpdateStatus.No: // has no update
	            ToastUtils.showMessageInCenter(UserCenterActivity.this, "已是最新版本");
	            break;
	        case UpdateStatus.Timeout: // time out
	        	ToastUtils.showMessageInCenter(UserCenterActivity.this, "检测超时");
	            break;
	        }
	    }
	});
}
 
Example 3
Source File: UmengUpdateAgentProxy.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
/**
 * 强制更新
 * 
 * @param context
 * @param listener
 */
public static void forceUpdate(Context context, UmengUpdateListener listener)
{
	// 检查更新
	UmengUpdateAgent.forceUpdate(context);
	UmengUpdateAgent.setUpdateListener(listener);
}
 
Example 4
Source File: AboutFragment.java    From AppPlus with MIT License 5 votes vote down vote up
@Override
    public boolean onPreferenceClick(android.preference.Preference preference) {
        String key = preference.getKey();
        //用if判断 效率不会很好 待改善
        if(key.equals(getString(R.string.preference_key_about))){
            String htmlFileName =  Utils.isChineseLanguage()?"about_ch.html":"about.html";
            DialogUtil.showCustomDialogFillInWebView(mContext, mContext.getSupportFragmentManager(), getString(R.string.preference_title_about), htmlFileName, "about");
            MobclickAgent.onEvent(mContext, "setting_about");
        }
        if(key.equals(getString(R.string.preference_key_score))){
//            NavigationManager.gotoMarket(mContext,getActivity().getPackageName());
            AppRate.with(getActivity()).showRateDialog(getActivity());
            MobclickAgent.onEvent(mContext, "setting_market");
        }
        if(key.equals(getString(R.string.preference_key_opinion))){
            NavigationManager.gotoSendOpinion(getActivity());
            MobclickAgent.onEvent(getActivity(), "send_email");
        }
        if(key.equals(getString(R.string.preference_key_check_update))){
            UmengUpdateAgent.setUpdateListener(new CheckUmengUpdateListener());
            UmengUpdateAgent.forceUpdate(mContext);
            MobclickAgent.onEvent(mContext, "setting_check_update");
        }
        if(key.equals(getString(R.string.preference_key_license))){
            DialogUtil.showCustomDialogFillInWebView(mContext, mContext.getSupportFragmentManager(), getString(R.string.preference_title_license), "license.html", "license");
            MobclickAgent.onEvent(mContext, "setting_license");
        }
        return false;
    }
 
Example 5
Source File: Configuration.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
@Click
void btn_update(){
    AppMsg.makeText(getSherlockActivity(),
            app.getString(R.string.tips_checking_for_update)
            , AppMsg.STYLE_INFO).show();
    UmengUpdateAgent.setUpdateAutoPopup(false);
    UmengUpdateAgent.setUpdateListener(umengUpdateListener);
    UmengUpdateAgent.forceUpdate(getSherlockActivity());
}
 
Example 6
Source File: MainActivity.java    From ChipHellClient with Apache License 2.0 5 votes vote down vote up
private void umengUpdate(final boolean auto) {
    if (!auto) {
        ToastUtil.show(getApplicationContext(), "正在检查新版本");
    }
    UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
        @Override
        public void onUpdateReturned(int updateStatus, UpdateResponse updateInfo) {
            switch (updateStatus) {
                case UpdateStatus.Yes: // has update
                    startActivity(UpdateActivity.getStartIntent(getApplicationContext(), updateInfo));
                    break;
                case UpdateStatus.No: // has no update
                    if (!auto) {
                        ToastUtil.show(getApplicationContext(), "没有新版本");
                    }
                    break;
                case UpdateStatus.NoneWifi: // none wifi
                    break;
                case UpdateStatus.Timeout: // time out
                    if (!auto) {
                        ToastUtil.show(getApplicationContext(), "网络超时");
                    }
                    break;
            }
        }
    });
    if (auto) {
        UmengUpdateAgent.update(this);
    } else {
        UmengUpdateAgent.forceUpdate(this);
    }
}
 
Example 7
Source File: RLUpdateHelper.java    From Roid-Library with Apache License 2.0 5 votes vote down vote up
/**
 * @param context
 * @param isQuietly
 */
public static void checkUpdate(final Context context, final boolean isQuietly) {
    final RLLoadingDialog pd = new RLLoadingDialog(context);
    if (!isQuietly) {
        pd.setMessage(R.string.is_checking_update);
        pd.show();
    }
    UmengUpdateAgent.setUpdateAutoPopup(false);
    UmengUpdateAgent.setUpdateOnlyWifi(false);
    UmengUpdateAgent.setOnDownloadListener(null);
    UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
        @Override
        public void onUpdateReturned(int status, UpdateResponse resp) {
            pd.dismiss();
            if (status == 0) {
                UmengUpdateAgent.showUpdateDialog(context, resp);
            } else {
                if (isQuietly) {
                    return;
                }
                if (status == 1) {
                    RLUiUtil.toast(context, R.string.UMNoUpdate);
                } else if (status == 2) {
                    RLUiUtil.toast(context, R.string.UMNoWifi);
                } else if (status == 3) {
                    RLUiUtil.toast(context, R.string.UMTimeout);
                }
            }
        }
    });
    UmengUpdateAgent.update(context);
}
 
Example 8
Source File: MainActivity.java    From ONE-Unofficial with Apache License 2.0 4 votes vote down vote up
private void setUmeng() {
        //对友盟统计日志加密
        AnalyticsConfig.enableEncrypt(true);
        //友盟统计不采集mac信息
        MobclickAgent.setCheckDevice(false);

        //禁止自动提示更新对话框
        UmengUpdateAgent.setUpdateAutoPopup(false);
        //禁止增量更新
        UmengUpdateAgent.setDeltaUpdate(false);
        UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
            @Override
            public void onUpdateReturned(int status, UpdateResponse updateResponse) {
                switch (status) {
                    case UpdateStatus.Yes:
                        //有更新
                        showUpdateDialog(updateResponse);
                        break;
                    case UpdateStatus.No:
                        //无更新
                        break;
                    case UpdateStatus.NoneWifi:
                        //无wifi
                        break;
                    case UpdateStatus.Timeout:
                        //超时
                        break;
                }
            }
        });
        //友盟设置检查更新,不限于wifi
        UmengUpdateAgent.setUpdateOnlyWifi(false);
        //禁用集成检测,否则会提示缺少xxx,然而我并不需要那些东西
        UmengUpdateAgent.setUpdateCheckConfig(false);
        //检查更新
        UmengUpdateAgent.update(this);

        //同步数据
        final FeedbackAgent agent = new FeedbackAgent(this);
//        agent.openFeedbackPush();      启用推送在小米手机上会有崩溃发生
        agent.sync();
        UserInfo userInfo = agent.getUserInfo();
        String nickname = ConfigUtil.readString("user", "nickname");
        if (TextUtils.isEmpty(nickname)) {
            final String n = generateNickname();
            Map<String, String> contact = new HashMap<>();
            contact.put("昵称", n);
            userInfo.setContact(contact);
            agent.setUserInfo(userInfo);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    boolean success = agent.updateUserInfo();
                    if (success) {
                        ConfigUtil.writeString("user", "nickname", n);
                    }
                }
            }).start();

        }
        //启用推送
//        PushAgent.getInstance(this).enable();  启用推送在小米手机上会有崩溃发生
    }
 
Example 9
Source File: SettingFragment.java    From v2ex-daily-android with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPreferenceClick(final Preference preference) {
    if(preference.getKey().equals(PREF_CONTACT)){
        Intent intent = new Intent(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:[email protected]"));
        if(intent.resolveActivity(getActivity().getPackageManager()) != null)
            startActivity(intent);
        else{
            AppMsg.makeText(getActivity(), "没有找到邮件程序", AppMsg.STYLE_CONFIRM).show();
        }
        return true;
    }else if(preference.getKey().equals(PREF_UPDATE)){
        UmengUpdateAgent.forceUpdate(getActivity());
        UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
            @Override
            public void onUpdateReturned(int i, UpdateResponse updateResponse) {
                if(getActivity() != null){
                    switch (i){
                        case UpdateStatus.No:
                            AppMsg.makeText(getActivity(), "您现在使用的就是最新版本", AppMsg.STYLE_INFO).show();
                            break;
                        case UpdateStatus.Timeout:
                            AppMsg.makeText(getActivity(), "网络超时", AppMsg.STYLE_CONFIRM).show();
                            break;
                    }
                }
                UmengUpdateAgent.setUpdateListener(null);
            }
        });
        return true;
    }else if(preference.getKey().equals(PREF_LOGIN)){
        if(logined){
            new AlertDialog.Builder(getActivity())
                    .setCancelable(true)
                    .setMessage("你确定要退出登录吗?")
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            logout();
                        }
                    }).setNegativeButton("取消", null)
                    .show();
        }else{
            startActivityForResult(new Intent(getActivity(), LoginActivity.class), REQUEST_CODE_LOGIN);
        }
        return true;
    }else if(preference.getKey().equals(PREF_SYNC)){
        final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), null, "Syncing...", true, true);
        V2EX.getUserInfo(getActivity(), new JsonHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                DebugUtils.log(response);
                try{
                    progressDialog.setMessage("Import Node Collections...");
                    JSONArray collectionsJson = response.getJSONObject("content").getJSONArray("collections");
                    String[] collections = new String[collectionsJson.length()];
                    for(int i = 0; i < collections.length; i++){
                        collections[i] = collectionsJson.getString(i);
                    }
                    mAllNodesDataHelper.removeCollections();
                    mAllNodesDataHelper.importCollections(collections);
                    long currentTimeMillis = System.currentTimeMillis();
                    PreferenceManager.getDefaultSharedPreferences(getActivity()).edit()
                            .putLong("sync_time", currentTimeMillis)
                            .commit();
                    progressDialog.setMessage("Finished");
                    progressDialog.dismiss();
                    preference.setSummary(TextUtils.getRelativeTimeDisplayString(getActivity(), currentTimeMillis));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        return true;
    }else {
        return false;
    }
}