I am writing an application manager for downloading files from the network. Just started learning the topic of services. File download will be carried out just through the service. There can be several downloads at the same time. Questions:

1) Do I understand correctly that 1 copy of the class of service = 1 download?

2) While downloading the file, the status and other info about uploading to activations are updated. Communication between the activation (fragment) and the service occurs through the intent (update status every second). Is it unprofitable to send with such regularity constantly a copy of the Download class (where the download info is included) in the activation (fragment)? Or you can do it in a more profitable way?

  • It is better to implement the download through AsyncTask, where there is a special method that can give information about the progress of implementation. - Andrew Grow
  • The download should work when you exit the application and when the application is minimized. Use AsyncTask in the service - and what does it change if I still need to somehow “communicate” with the activation? - Ruben
  • Ok, then another solution. Activation is bound to the service and is registered with it (implement methods of binding and storing the link to the activation). The service launches download streams (by the way, the service is always one instance, so implement many streams) and reports the progress to it via the link Activiti. When Activity closes, it must deregister. Something like this) - Andrew Grow
  • Thanks for the advice. A question on the Intentservice - if it implements the functionality to complete a task, will it be correct to use it for one separate task? - Ruben

0