Hi,
So you are using a persistent thread that runs your application ? This is currently the only way to keep your application running.
For real-time communication, you could use MQTT instead of polling. In v24 the MQTT is available for Windev Mobile, but if you only target Android, there is Java code available to implement the MQTT in v23. The moment you send a message from a publisher to a subscriber it is received (in most cases almost) instantly. It is for the application event driven.
One Idea could be that you send a High priority FireBase Push Notification to the application. And thereby wake the application or even put it on the foreground. This is according to Google one of the only ways to keep things running on Android 8.
Normally the application should only be killed by android if it is in the background and is not in use (for some long time) or uses a lot of memory, but this should take a few hours.
If you use Push Notifications to bring your app to the foreground, then the app is in use again. Keeping it a live.
We are also having some problems with Android 8, but it is indeed better to exclude the App from,any battery saving options.
Google has also blocked the scheduler and timer-task when the device is in IDLE mode (I think about 4 hours of not touching or moving the device, aka at night beside your bed). The internet connection is shifted in time, tasks are rescheduled for a later time. The Android 8 wakes up after a while to let apps do some work, then all goes back to sleep. The longer the device is in Idle Mode, the longer it will take before Android will give the Apps some CPU and Internet time.
As long as the battery stuff for that app is OFF and you keep moving or screen is on the device should not enter this IDLE state.
I did had some problem, only on Android 8 that the application was killed, it seems that Android 8 is more sensitive for accessing the GUI from a thread. Code that ran fine on Android 4.x had problems on Android 8. After I fixed this bug, it was more stable on Android 8.
Another things you could misuse is the motion detection, a procedure is called every time the mobile detects Motion. You could try to do some stuff there to wake up the device/app to keep it running.
You could implement a kind of Heartbeat, as long as the application is running, your server/Back-end knows the software is active. Once the heartbeat is not received anymore, the Server could send a High Priority Push Notification, so that the application is started again.
If you did find the ultimate solution, please post in :-)
If you have other questions, please feel free to ask. Our application is running 24/24 7/7, (on older Androids), but on Version 8 this is much less stable. Google may have implemented some AI to manage application and Battery, but they seem to have forgotten that for some business use we don't really care about battery live, the application should be running all the time !!
Have a nice day
Danny