androidx.work.Worker.doWork()
stopped working 3-4 days ago. It has been working 2-3 years before that without any errors.
Before the problem occurred the method was called every 30 minutes.
But now it is called only when I click on the app and it's brought to the front - after the Activity.onResume()
is called.
I added corresponding log statements to come to this conclusion.
I assume there must be some change in the Android system. However Android version (14) hasn't changed. I also haven't committed any changes to the app source code since a month or two and didn't update it on the phone. One UI may have been updated, but I don't know how it could affect it.
I added the app to the list Never auto sleeping apps
but it didn't seem to have any effect.
Any recommendations are welcome. If some app code is needed I'll post it, but honestly I don't know how it can help.
My next step would probably include the following:
doWork()
will be called on the emulator app every 30 minutes the problem must be in Android system on the phoneI've remembered that I turned the option Battery -> Power saving
on 3-4 days ago. After I turned it off doWork()
began to work in background again.
The description of the option says:
Background network usage, syncing, and location checking will be limited, and Motion smoothness will be changed to Standard (60 Hz)
It is quite understandable that they don't put more detailed information in this description - e.g. Worker.doWork() execution will be limited - as most phone users won't understand it. However for me as developer this was quite unexpected. But I'm not sure whether it's mentioned somewhere in Android/Android SDK documentation...