Filedownloader: getSoFar and getTotal not work correctly

Created on 25 May 2017  ·  3Comments  ·  Source: lingochamp/FileDownloader

getTotal and getSoFar methods not work until at least one download created .
when I firstly open app in Fragment 1 I log getTotal for an id and it returns 0 . after i go somewhere for example Fragment 2 and create a download and came back to Fragment 1 its work and show me true size
should I set any setting to enable it or it is a bug ?

question

Most helpful comment

That is a feature, not Bug.

You also can get tips from the logcat it is the warning primary log.

Because of the data of Task is persist on the databse and the database only can access on the FileDownloadService, so If you want getTotal or getSoFar you have to ensure the service is running first.

It is too inconvenient, How to optimize?

Following method is used for such case:

  • FileDownloader.insureServiceBind()
  • FileDownloader.insureServiceBindAsync()
  • FileDownloader.bindService(Runnable)

P.S. Any task is running also can start the FileDownloadService.

All 3 comments

That is a feature, not Bug.

You also can get tips from the logcat it is the warning primary log.

Because of the data of Task is persist on the databse and the database only can access on the FileDownloadService, so If you want getTotal or getSoFar you have to ensure the service is running first.

It is too inconvenient, How to optimize?

Following method is used for such case:

  • FileDownloader.insureServiceBind()
  • FileDownloader.insureServiceBindAsync()
  • FileDownloader.bindService(Runnable)

P.S. Any task is running also can start the FileDownloadService.

Thanks for your reply , but how can I run service without start downloading a file ?

@vd92

Following method is just what you want( run service without start downloading a file ), they just start and bind service:

  • FileDownloader.insureServiceBind()
  • FileDownloader.insureServiceBindAsync()
  • FileDownloader.bindService(Runnable)
Was this page helpful?
0 / 5 - 0 ratings