Fetch: I want the download to start instantly?

Created on 19 Oct 2018  路  4Comments  路  Source: tonyofrancis/Fetch

I have two activities so:

  1. One for enqueueing a download at runtime and it may enqueue more than one download. I open an instance of fetch with namespace "ALL_DOWNLOADS" and enqueue a request. But I never display any progress in this activity.
  1. The second activity displays the progress of all downloads. So I open an instance of Fetch with the same namespace and display the progress for each download.

I can see all downloads, but something is happening: The download does not start until I enter the next activity. I want the download to start instantly in the background just after enqueueing in the first activity. And only display progress when I go to the second activity.

How can I achieve this??

help wanted

All 4 comments

@Xenolion
Make sure the new request you are creating has the downloadOnEnqueue property set to true. Example:

Request request = new Request("url", "file");
request.setDownloadOnEnqueue(true);

Let me know if this helps.

@Xenolion Just had a chance to have a look at your issue again. After Enqueuing downloads, they are placed in the queue. The issue you may be experiencing is that before the downloads start the instance of Fetch in the first Activity is garbage collected causing the downloads not to process unless the new instance of Fetch is created on the second activity. The best solution is to share a global instance of Fetch with the same namespace.

I later on solved by Making Fetch instance inside a service and making download start since the service keeps on running...So when I enter the Second Activity I can now find some downloads progress is already 30% or more... and thats what I wanted. Did you change this behavior? Was it like this even for previous versions?

the behavior was not changed

Was this page helpful?
0 / 5 - 0 ratings