Closed mraj0045 closed 6 years ago
You should create a global DownloadManager, and then you can cancel task.
What if I close the app and open again while downloading? will the global DownloadManager work?
What do you mean close the app? If your app exit totally, the download manager will stop and no tasks.
while downloading some file I'm closing the app. The download happens in the background. if I open the app again and try to cancel the download, will it work if using global DownloadManager?
Do you mean you have a service in background? If so, the gloabl DownloadManager will work.
yes
You should create an instance of DownloadManager in your service, so that you can control the downloading.
What I want to do is that there is a separate page for Managing downloads. There I can pause, resume, cancel the download. But download happens in a separate service. Even if create an instance Of DownloadManager in service, how will I able to perform (pause, resume, cancel) from the activity.
I think you should check communication between activity and service on google.
The download is not canceling when used inside FirebaseJobDispatcher. When canceling the job manually, the download still continues even after the job canceled.
And also tried to cancel the download from the code manually. But cancel download only works if the same "object" created for downloading the file is used for canceling. If I create a new DownloadManager Object and cancel the download, it should cancel.