update icon indicating copy to clipboard operation
update copied to clipboard

更新安装包下载完成后总是提示“下载失败:检验错误”,但是MD5是没错的

Open Jorble opened this issue 7 years ago • 1 comments

`/** * 检查更新 */ private void checkUpdate() { UpdateUtil.clean(getContext());//清除sp的忽略标志和apk文件缓存 UpdateManager.setDebuggable(true); UpdateManager.setWifiOnly(false); check(); }

void check() {
    UpdateManager.create(getContext()).setChecker(new IUpdateChecker() {
        @Override
        public void check(ICheckAgent agent, String url) {
            //定制查询更新
            L.i("update " + "checking");
            HttpURLConnection connection = null;
            try {
                connection = (HttpURLConnection) new URL(url).openConnection();
                connection.setRequestProperty("Accept", "application/json");
                connection.connect();
                if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    agent.setInfo(UpdateUtil.readString(connection.getInputStream()));
                } else {
                    agent.setError(new UpdateError(UpdateError.CHECK_HTTP_STATUS, "" + connection.getResponseCode()));
                }
            } catch (IOException e) {
                e.printStackTrace();
                agent.setError(new UpdateError(UpdateError.CHECK_NETWORK_IO));
            } finally {
                if (connection != null) {
                    connection.disconnect();
                }
            }
        }
    }).setUrl(mCheckUrl).setManual(true).setNotifyId(998).setParser(new IUpdateParser() {
        @Override
        public UpdateInfo parse(String source) throws Exception {
            //定制解析过程
            UpdateInfo info = UpdateInfo.parse(source);
            L.i("url=" + info.url);
            return info;
        }
    }).setOnNotificationDownloadListener(new NotificationDownloadListener(getContext(), 998))
            .check();
}`

Jorble avatar Jun 27 '17 07:06 Jorble

能否提供你的文件下载地址和文件md5?

czy1121 avatar Nov 03 '17 08:11 czy1121