com.umeng.update.UpdateResponse Java Examples

The following examples show how to use com.umeng.update.UpdateResponse. 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: AboutFragment.java    From AppPlus with MIT License 6 votes vote down vote up
@Override
public void onUpdateReturned(int updateStatus, UpdateResponse updateInfo) {
    switch (updateStatus) {
        case UpdateStatus.Yes: // has update
            UmengUpdateAgent.showUpdateDialog(mContext, updateInfo);
            break;
        case UpdateStatus.No: // has no update
            DialogUtil.showSinglePointDialog(mContext,mContext.getString(R.string.update_point_no_update));
            break;
        case UpdateStatus.NoneWifi: // none wifi
            DialogUtil.showSinglePointDialog(mContext, mContext.getString(R.string.update_point_no_wifi));
            break;
        case UpdateStatus.Timeout: // time out
            DialogUtil.showSinglePointDialog(mContext, mContext.getString(R.string.update_point_time_out));
            break;
    }
}
 
Example #4
Source File: Configuration.java    From iSCAU-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdateReturned(int updateStatus,UpdateResponse updateInfo) {
    switch (updateStatus) {
        case UpdateStatus.Yes: // has update
            UmengUpdateAgent.showUpdateDialog(getSherlockActivity(), updateInfo);
            break;
        case UpdateStatus.No: // has no update
            Toast.makeText(getSherlockActivity(), "没有更新", Toast.LENGTH_SHORT).show();
            break;
        case UpdateStatus.NoneWifi: // none wifi
            Toast.makeText(getSherlockActivity(), "没有wifi连接, 只在wifi下更新", Toast.LENGTH_SHORT).show();
            break;
        case UpdateStatus.Timeout: // time out
            Toast.makeText(getSherlockActivity(), "超时", Toast.LENGTH_SHORT).show();
            break;
    }
}
 
Example #5
Source File: MyUpdateListener.java    From wakao-app with MIT License 6 votes vote down vote up
@Override
public void onUpdateReturned(int updateStatus,
		UpdateResponse updateInfo) {
	switch (updateStatus) {
	case 0: // has update
		Log.i("--->", "callback result");
		UmengUpdateAgent.showUpdateDialog(mContext, updateInfo);
		break;
	case 1: // has no update
		Toast.makeText(mContext, "已经是最新版本", Toast.LENGTH_SHORT)
				.show();
		break;
	case 2: // none wifi
		Toast.makeText(mContext, "没有wifi连接, 只在wifi下更新", Toast.LENGTH_SHORT)
				.show();
		break;
	case 3: // time out
		Toast.makeText(mContext, "超时", Toast.LENGTH_SHORT)
				.show();
		break;
	case 4: // is updating
		/*Toast.makeText(mContext, "正在下载更新...", Toast.LENGTH_SHORT)
				.show();*/
		break;
	}
}
 
Example #6
Source File: AboutActivity.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
/**
 * 检测更新
 * 
 * @param v
 */
private void onUpgradeClick(View v)
{
	// 检查更新
	UmengUpdateAgentProxy.forceUpdate(getApplicationContext(), new UmengUpdateListener()
	{

		@Override
		public void onUpdateReturned(int updateStatus, UpdateResponse updateResponse)
		{
			switch (updateStatus)
			{
				case 0:
				{
					// has update
					//UmengUpdateAgent.showUpdateDialog(mContext, updateResponse);
					break;
				}
				case 1:
				{
					// has no update
					showToast(R.string.update_not_new_version);
					break;
				}
				case 2:
				{
					// none wifi
					Log.D(TAG, "" + getString(R.string.update_only_wifi));
					break;
				}
				case 3:
				{
					// time out
					showToast(R.string.update_time_out);
					break;
				}
			}
		}
	});
}
 
Example #7
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 #8
Source File: UpdateActivity.java    From ChipHellClient with Apache License 2.0 5 votes vote down vote up
public static Intent getStartIntent(Context context, UpdateResponse updateResponset) {
    Intent intent = UpdateActivity_.intent(context)
            .updateResponse(updateResponset)
            .get();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    return intent;
}
 
Example #9
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 #10
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 #11
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;
    }
}