In my app users have an option to download all necessary data from the server to work offline. But this process can take a lot time - up to 10 minutes with good internet connection. Of course, users don’t want to look on downloading screen for a long time, and they turn off screen, or switch to another app. After that action my app is running in the background but unexpectedly stops running some time later.
I tried to use BackgroundTask.beforeExit, but it didn’t work. I couldn’t understand why, and I spent a lot of time to try getting it work. And I was very badly surprised when I found in the capacitor sources next lines:
// No-op for now as Android has less strict requirements for background tasks
This method do nothing!
So… Is there any good practices to handle such situation on android?