Android Question How to download a file every 4 hours with a service?

Erel

B4X founder
Staff member
Licensed User
Longtime User
Why?
This is a solution from 2011 where the first line tells you that you should use HttpUtils2 instead. Note that HttpUtils2 was later replaced with OkHttpUtils2 though the API is exactly the same.

Relevant tutorial: https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/

About the service. You need to schedule the service with StartServiceAt.
Once the service is started you need to acquire a partial lock with PhoneWakeState. Make the download and call Service.StopAutomaticForeground.
Also call StartServiceAt to schedule the next run.
 
Upvote 0

Edgardo PuntoCom

Member
Licensed User
Longtime User
Why?
This is a solution from 2011 where the first line tells you that you should use HttpUtils2 instead. Note that HttpUtils2 was later replaced with OkHttpUtils2 though the API is exactly the same.

Relevant tutorial: https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/

About the service. You need to schedule the service with StartServiceAt.
Once the service is started you need to acquire a partial lock with PhoneWakeState. Make the download and call Service.StopAutomaticForeground.
Also call StartServiceAt to schedule the next run.
Thank you. I will try
 
Upvote 0
Top