lingochamp / okdownload

A Reliable, Flexible, Fast and Powerful download engine.
Apache License 2.0
5.13k stars 767 forks source link

如何在杀了应用后,可以断点续传下载 #499

Open vincent911001 opened 1 year ago

vincent911001 commented 1 year ago

OkDownload Version

v1.0.7

Problem Describe

            task = DownloadTask.Builder(url, File(path))
                .setFilename(filename)
                .setMinIntervalMillisCallbackProcess(200)
                .setPassIfAlreadyCompleted(false)
                .build()

重启应用后,怎么能重新初始化一个能断点续传的DownloadTask

DownloadTask this.id = OkDownload.with().breakpointStore().findOrCreateId(this);

如果重新初始化了,在BreakPointStore会找不到id,然后就不能续传了, 请问我理解对吗?

DownloadCall

            BreakpointInfo info;
            try {
                BreakpointInfo infoOnStore = this.store.get(this.task.getId());
                if (infoOnStore == null) {
                    info = this.store.createAndInsert(this.task);
                } else {
                    info = infoOnStore;
                }

                this.setInfoToTask(info);

有其他方案吗?感谢