Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in download manager android

Using Android Download Manager i am trying to implement multiple download of pdf files synchronously (ie,an instance of the request is generated after successful completion of the previous request),soon after a DOWNLOAD_SUCCESS notification in the broadcast receiver,a duplicate copy of the same request(with the same request id ) is generated and the DownlaodManager is initiated implicitly.For the second time the download fails,and DownlaodManager gives DownloadManager.status = ERROR CANNOT RESUME.Hence,pdf is not downloaded.This happens only when i try synchronized multiple download. Any help is appreciated.

like image 534
HjK Avatar asked Nov 13 '22 04:11

HjK


1 Answers

I noticed that if you start another download immediately when current has finished, this error occurs. So, I solved this problem by inserting a sleep time in the current Thread between the finish and the start of the next download... I used Thread.sleep(1000), but you can try others values. (make sure you are not doing it in UIThread). Works nice for me ;)

like image 163
Gilian Avatar answered Nov 16 '22 04:11

Gilian