Android: Scheduling Long Background Task When System Is Idle
I'm writing an Android application that records video and then runs post processing on recorded video. Since post processing may take a while (up to an hour) I'm scheduling a servi
Solution 1:
You need to use a Foreground service
.
They are one of the few methods left to run long background tasks. The user must know what's happening on his device and he should have the ability to decide to stop it or not.
You can read how to implement basic Foreground Services here, and there are a lot of guides on the internet on how to implement them in an advanced manner.
Remember that even a Foreground Service can be stopped by the OS if the system is in extreme memory pressure and the only things left to destroy are foreground services. So you should always have a recovery procedure if that happens.
Post a Comment for "Android: Scheduling Long Background Task When System Is Idle"