Welcome! Log In Create A New Profile


[WM] Android 8 background processing

Posted by apredl 
[WM] Android 8 background processing
December 15, 2018 12:30PM
Hi @everyone,

I have a litte (for me big) problem with a Android 8 mobile device, since Android 4.1 everything works find with Android, but now I have lots of problems with background processing, my APP stops working in background for 5-10 minutes if the user puts the device in standby....

It is a HFSQL connection with self made synchronization, it works fine until Android 8... I confirmed, that in Android 7.1 it works and in Android 8 it stops in background processing for a long time (only if I uncheck background monitoring for the APP, if I don't do that, the APP stops working at all!)

I read in https://www.dev-insider.de/background-execution-limits-in-android-oreo-a-660498/ (website is in german) that we must use "JobScheduler" or "Firebase JobDispatcher" or "Android-Job-library of Evernote"...

So my question is, should I contact PcSoft or had someone the same problem, a solution and can help me??

Alexander Predl
Stefan Kern
Re: [WM] Android 8 background processing
December 16, 2018 07:21PM
Hi Alex,

have a look at BackgroundtaskAdd()


From the help:

The task will be run when the application is not started or when the application is in background. If the application is displayed in the foreground, its execution will be postponed.

Best Regards

Re: [WM] Android 8 background processing
December 17, 2018 06:30PM
Hi Stefan,

really thx for reply, I found the BackgroundTaskAdd() too, but our app needs 1-2 second respond, not every 5-15 minutes respond... so our APP worked since Android 7.1 which I tested hours and hours. With our new Android 8.0 phones I can set background processing to not watching and power control to "can use energy as much as needed" but there is anyway a delay of 5-10 minutes, then a "roundtrip" of synchronisation is made...

So I think PcSoft has implemented the JobSheduler as new the BackgroundTask...

I need a background app like in Android 7.1 every second a "roundtrip" to our server, because we have a waiter call which needs to update every second, then we have a bluetooth printer, which need to update every minute or so. Then we need to stay up-to-date server with the mobile database, so when our user imputs some data, the data needs to be synchronous, even the user puts the device in standby.

My last option is to exchange the phone with another phone running Android 7.1

Re: [WM] Android 8 background processing
December 19, 2018 06:05PM

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
Re: [WM] Android 8 background processing
December 19, 2018 06:36PM
Hi Danny,

thanks a lot for your detailed explanation! We will handle - and hopefully solve - that as soon as Alex comes back from our customer. This customer is located ~400 kilometers from the office and driving there in winter time is no joy.

Kind regards,
Guenter Predl

Your Email:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.