Android Question HttpUtils2Service & Doze Mode

FrankBerra

Active Member
Licensed User
Longtime User
Hello there!
I am facing problems with doze mode while i try to send data to my servers.

I have developed an app that sends data regularly to servers: everything works except when Doze Mode starts.
The service is started in foreground mode and while the local computations of the service works correctly, when doze mode is enabled the service stops/freezes when i call Job.Download2, for example with the following code:

B4X:
    Job.Download2(URL, Array As String("a", a, "b", b))       
    Wait For (Job) JobDone(Job As HttpJob)
    ....

Probably the OS doesn't allow to connect to internet while in Doze mode but i need to know if Job.Success is True or False but no result or exception is rised during doze mode.
How can i deal with this problem?

Thanks in advance!
 

FrankBerra

Active Member
Licensed User
Longtime User
As explained here: https://developer.android.com/topic/performance/vitals/wakelock
it says: "In general, your app should avoid partial wake locks because it is too easy to drain the user's battery."

I think that i don't need a partial lock in my case because the service is still running correctly except when it needs to contact the server.

If the app can't contact the server it isn't a big problem: the data will be sent next time. It becames a problem if the app can't give me a response about Job.Success == True or false. In Doze mode it should say me Job.Success = False.
If i don't receive any respose the service is like frozen at:
Wait For (Job) JobDone(Job As HttpJob)

If it can't reach the end, for example, it can't call Service.StopAutomaticForeground, or stop timers or GPS listening and so on.
 
Upvote 0

FrankBerra

Active Member
Licensed User
Longtime User
I suppose it is running because data are regularly saved on local database.
My Logs says that sub for contacting server is started but no other informations.
On B4A console it says:
B4X:
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **

And then no other additional informations/logs until the service to acquire data is started again by a schedule.
 
Upvote 0
Top