F FrankBerra Active Member Licensed User Longtime User Nov 25, 2018 #1 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: Code: 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!
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: Code: 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!
KMatle Expert Licensed User Longtime User Nov 26, 2018 #2 Search for partial lock and check if your app is allowed to run in the background (settings of your phone) Upvote 0
Search for partial lock and check if your app is allowed to run in the background (settings of your phone)
F FrankBerra Active Member Licensed User Longtime User Nov 26, 2018 #3 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
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.
Erel B4X founder Staff member Licensed User Longtime User Nov 27, 2018 #4 Are you sure that it is really running? Are you monitoring the logs? Upvote 0
F FrankBerra Active Member Licensed User Longtime User Nov 27, 2018 #5 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: Code: *** 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
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: Code: *** 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.
Erel B4X founder Staff member Licensed User Longtime User Nov 27, 2018 #6 Worth adding more log messages to make sure that Job.Download is called. I don't see why your app fails if there is no response. You should use StartServiceAt to make a download every x minutes. Upvote 0
Worth adding more log messages to make sure that Job.Download is called. I don't see why your app fails if there is no response. You should use StartServiceAt to make a download every x minutes.