For an activity I have, I want to clean up some files upon on destroy. Would it be better to keep that in a service, or would using coroutines be good enough?
The task should be independent of the activity lifecycle, and does not depend on context.
09/27/2018, 2:01 PM
coroutines or threads don't mean anything for Android. Using them without any foreground component like activity just makes your app eligible to be killed before cleanup. Not to mention the fact that starting Android Pie's bucket system, CPU could be relinquished in certain cases
Have some foreground service during cleanup and launch coroutines from that service.
FYI, camera app launches a foreground service for HDR processing of captured photo, food for thought 🙂
09/27/2018, 2:07 PM
Ah okay that was what I was wondering. I usually never use thread pools for this reason.